patd1
asked on
Process.Start(Command, Arguments) does not work on IIS
I am running windows server 2003 R2 with IIS 6.0. I created a web app that runs an exe from C# code using Process.Start(Command, Arguments). It works fine when I run it from within Visual Studio, but does not work when I published this app on IIS 6.0. Please guide on how to set it up to work on IIS. I found an article on http://support.microsoft.com/kb/555134 which talks about a similar problem and suggests to Allow Service to Interact with Desktop on IIS Admin Service. I did that, but there seems to be no change. My app still does not seem to execute the exe called in Process.Start(Command, Arguments).
If you're running from within ASP.NET, are you calling the executable with an absolute path? If you use a relative path, then you will need to call Server.MapPath() as the working directory for ASP.NET apps is the IIS bin directory (I believe) and not the web site's physical location on disk.
I would also check to make sure that your Virus Scan software isn't doing anything to block the exe from running.
ASKER
I am getting the path from web.config file as follows:
<appSettings>
<add key="HL7FileServerIn" value="\\mywebserver\Orders\"/>
<add key="MappingCommand" value="\\mywebserver\Inetpub\wwwroot\MyWebsite\AppFolder\bin\Debug\Mapping.exe"/>
//parse message
string MappingCommand = ConfigurationManager.AppSettings["MappingCommand"].ToString();
string Filepath = HL7FileServerIn + FName;
string MappingArguments = " /FileName " + Filepath;
Process p = Process.Start(MappingCommand, MappingArguments);
ASKER
I just changed the Application Pool Properties of IIs to use Local service to try to see if it works. Now I get a different error:
System.ComponentModel.Win3 2Exception : No network provider accepted the given network path at System.Diagnostics.Process .StartWith ShellExecu teEx(Proce ssStartInf o startInfo) at System.Diagnostics.Process .Start() at System.Diagnostics.Process .Start(Pro cessStartI nfo startInfo) at System.Diagnostics.Process .Start(Str ing fileName, String arguments) at WriteORM.WrtieOrderMessage (String MsgID, String FName) in c:\Inetpub\wwwroot\..\..\W riteORM.cs :line 28 at _Default.ParseOrderMessage (Object sender, GridViewCommandEventArgs e) in c:\Inetpub\wwwroot\CSIAcce ssioning\D efault.asp x.cs:line 578
line 28 is Process p = Process.Start(MappingComma nd, MappingArguments);
line 578 is calling the method that has the above at line 28. (W.WrtieOrderMessage(MID, FName);)
Thanks
System.ComponentModel.Win3
line 28 is Process p = Process.Start(MappingComma
line 578 is calling the method that has the above at line 28. (W.WrtieOrderMessage(MID, FName);)
Thanks
You may have to set "Load User Profile" to true in the IIS app pool settings. Make sure the user which your app pool is running as has permissions to that network path.
ASKER
How to do that in IIS6.0 (Windows server 2003 R2)?
A couple of observations/questions...
1. Just to be clear calling Process.Start() in the server code is going to run your program on the server itself, not on the computer that's viewing the website.
2. If the program you're starting is on the webserver itself, instead of using a UNC network path try setting MappingCommand to C:\inetpub\wwwroot\MyWebSi te\AppFold er\bin\Deb ug\Mapping .exe. Or better yet do what kaufmed suggested, set MappingCommand to ~/AppFolder/bin/Debug/Mapp ing.exe and then use Process.Start(Server.MapPa th(Mapping Command), MappingArguments)
3. I notice the path you're trying to execute is \\server\inetpub\wwwroot.. . - is C:\Inetpub on the server shared as inetpub?
4. Does Mapping.exe have a user interface - i.e. does it show any Windows?
1. Just to be clear calling Process.Start() in the server code is going to run your program on the server itself, not on the computer that's viewing the website.
2. If the program you're starting is on the webserver itself, instead of using a UNC network path try setting MappingCommand to C:\inetpub\wwwroot\MyWebSi
3. I notice the path you're trying to execute is \\server\inetpub\wwwroot..
4. Does Mapping.exe have a user interface - i.e. does it show any Windows?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I had suggested using a local path, as opposed to the malformed UNC path, in my comment http:#34089488
ASKER
Thanks. My issue was resolved before I got that solution.
Fair enough - works for me. Thanks for updating us...