Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to call exe of report builder from web application (code in vb.net) but work well through code
but it doesn't work while i 'll publish it in iis then it's not work.
I have already give rights to folder of read/write

Code below
VB
Protected Sub Button1_Click(sender As Object, e As EventArgs)
    Dim p As New Process()
    p.StartInfo.FileName = "D:\yourapplication.exe"
    p.Start()
End Sub


Plz suggest me.
Posted
Comments
[no name] 23-Jun-14 12:45pm    
What does "not work" mean? Does the code run at all? Does the application run at all? Does the application run but not produce the result you expect?
Sergey Alexandrovich Kryukov 23-Jun-14 16:41pm    
What's the use? How can you make sure the user has the volume D? There are no cases when hard-coded path name could be useful.
And starting the process is much simpler:
System.Diagnostics.Process.Start(yourFileName);
—SA

Please see my comment to the question and the original documentation: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start%28v=vs.110%29.aspx[^].

As to the paths to some files, they can always be calculated during runtime, based on user input or some configuration files. You cannot just use hard-coded drive "D" (or "C", does not matter) — who knows what is it on each particular system? Not all system have D, not all have C (it may come at surprise for you, but this is so). For some valid directories you can use, please see my past answers:
How to find my programs directory (executable directory),
How to find my programs directory (current directory, "special folders").

Besides, it's generally not a good idea to start a separate process at all. Processes are well-isolated and usually not designed to communicate.

—SA
 
Share this answer
 
Comments
Maciej Los 23-Jun-14 17:07pm    
Valuable answer, +5!
Sergey Alexandrovich Kryukov 23-Jun-14 18:18pm    
Thank you, Maciej.
—SA
khyati.ptl 24-Jun-14 2:47am    
I have write below code

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Try


Label1.Text = "hi"
Dim p As New Process()

p.StartInfo.FileName = HttpContext.Current.Server.MapPath("Report Builder 3.0\MSReportBuilder.exe")

p.Start()
Label1.Text = "hello"
Label1.Text = HttpContext.Current.Server.MapPath("Report Builder 3.0\MSReportBuilder.exe")
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub


but stilll exe not call
and label message is print successfull but exe not call
Web based application uses Server.MapPath[^] method to define path to the file(s). On the other site, have a look here: Process.Start[^] method:
MSDN wrote:
Note

ASP.NET Web page and server control code executes in the context of the ASP.NET worker process on the Web server. If you use the Start method in an ASP.NET Web page or server control, the new process executes on the Web server with restricted permissions. The process does not start in the same context as the client browser, and does not have access to the user desktop.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 23-Jun-14 18:18pm    
Sure, this is the thing with the Web applications... a 5.
—SA
Maciej Los 24-Jun-14 5:00am    
Thank you, Sergey ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900