Link to home
Start Free TrialLog in
Avatar of zgreen
zgreenFlag for United States of America

asked on

Error when executing exe from ASP.NET page on Server 2008 IIS 7 server

I am trying to execute an EXE (cmd.exe to be exact) on the web server using an asp.net web page. When I execute the EXE on a server 2003 box with IIS 6.0 it works fine. When I try to execute it on a server 2008 box with IIS 7.0, I receive this error in the Application Event Log (no error is caught by my program):

"Faulting application cmd.exe, version 6.0.6001.18000, time stamp 0x47919317, faulting module kernel32.dll, version 6.0.6001.18000, time stamp 0x4791adec, exception code 0xc0000142, fault offset 0x00000000000b1188, process id 0x10ec, application start time 0x01c98c5d97fde641."

Because it works on the IIS 6.0 box, I immediately think that I may have to configure something in IIS 7.0's configuration to allow the running of an EXE from an ASP.net page. Any ideas?

Is there a better forum for my question?

Thanks.
Zach
StreamReader sr = null;
ProcessStartInfo psi = null; 
 
try {
psi = new ProcessStartInfo("cmd.exe", "ping 10.147.0.132");
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
psi.Domain = "domain";
psi.UserName = "username";
psi.Password = password;
psi.UseShellExecute = false; 
 
//start the process
Process p = Process.Start(psi);
p.WaitForExit();
sr = p.StandardOutput; 
 
//put output to message
lblMessage.Text = "Result: " + sr.ReadToEnd();
} catch (Exception ex) {
lblMessage.Text = ex.Message;
}

Open in new window

Avatar of DropZone
DropZone
Flag of United States of America image

You are attempting to run "cmd.exe" on the Windows 2008 Server, which may be locked-down.  You need to grant access to the IIS account that is executing your web application to run the "cmd.exe" shell.

This article explains what you need to do:
    http://support.microsoft.com/default.aspx/kb/311481

    -dZ.
Avatar of zgreen

ASKER

In the code you will see that I am assigning a domain, username, and password to the ProcessStartInfo object. That user does have rights to access anything on the server. If I run it without passing the username and password, I do receive an error that the user does not have the rights to access the file, When I do pass the username and password I don't receive the "no accees" error, I receive the "Faulting Application" error above.
Avatar of Ted Bouskill
It's funny.  Microsoft is spending money trying to make Windows and IIS more secure and then questions like this come along to make it less secure.  Sadly Microsoft gets the blame when it's servers are hacked.

Is this an intranet site?  What are you trying to achieve on the command line.  Maybe we can help you get the same result without lowering the security of your server.
From the code, he appears to be trying to perform a "ping".

     -dZ.
Avatar of zgreen

ASKER

I am trying to successfully execute the code above on server 2008 IIS 7.
Are you simply trying to verify that the server at that address is running?  You can do that directly in C# code without shelling out to the command prompt.
Avatar of zgreen

ASKER

cmd.exe is simply being used as an example of not being able to run an exe successfully. every exe i try to run results in the "Faulting Application" error.
ASKER CERTIFIED SOLUTION
Avatar of Ted Bouskill
Ted Bouskill
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zgreen

ASKER

Thanks.