Solved

Process.Start(Command, Arguments) does not work on IIS

Posted on 2010-11-08
12
3,856 Views
Last Modified: 2012-05-10
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).

 
0
Comment
Question by:patd1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34087066
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.
0
 
LVL 6

Expert Comment

by:jdfulton
ID: 34087507
I would also check to make sure that your Virus Scan software isn't doing anything to block the exe from running.
0
 

Author Comment

by:patd1
ID: 34087640
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);

Open in new window

0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:patd1
ID: 34087706
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.Win32Exception: No network provider accepted the given network path at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(String fileName, String arguments) at WriteORM.WrtieOrderMessage(String MsgID, String FName) in c:\Inetpub\wwwroot\..\..\WriteORM.cs:line 28 at _Default.ParseOrderMessage(Object sender, GridViewCommandEventArgs e) in c:\Inetpub\wwwroot\CSIAccessioning\Default.aspx.cs:line 578  
 
line 28 is         Process p = Process.Start(MappingCommand, MappingArguments);  
line 578 is  calling the method that has the above at line 28. (W.WrtieOrderMessage(MID, FName);)

Thanks
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34087778
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.
0
 

Author Comment

by:patd1
ID: 34087895
How to do that in IIS6.0 (Windows server 2003 R2)?
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34089488
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\MyWebSite\AppFolder\bin\Debug\Mapping.exe.  Or better yet do what kaufmed suggested, set MappingCommand to ~/AppFolder/bin/Debug/Mapping.exe and then use Process.Start(Server.MapPath(MappingCommand), 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?
0
 

Accepted Solution

by:
patd1 earned 0 total points
ID: 34093039
The issue was resolved yesterday by changing the UNC to drive letter.

Thanks.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34095060
I had suggested using a local path, as opposed to the malformed UNC path, in my comment http:#34089488
0
 

Author Comment

by:patd1
ID: 34095676
Thanks. My issue was resolved before I got that solution.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 34096145
Fair enough - works for me.  Thanks for updating us...
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question