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

zgreenAsked:
Who is Participating?
 
Ted BouskillSenior Software DeveloperCommented:
Back to my original comment.  A web application has been designed to run in a sandbox and Microsoft is actually trying to prevent you from running other EXE's to protect your server.  However, if you add the EXE to the 'Web Server Extensions' and make sure any DLL's the EXE uses are trusted or in the GAC then you can execute it safely.
0
 
DropZoneCommented:
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.
0
 
zgreenAuthor Commented:
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.
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
Ted BouskillSenior Software DeveloperCommented:
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.
0
 
DropZoneCommented:
From the code, he appears to be trying to perform a "ping".

     -dZ.
0
 
zgreenAuthor Commented:
I am trying to successfully execute the code above on server 2008 IIS 7.
0
 
Ted BouskillSenior Software DeveloperCommented:
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.
0
 
zgreenAuthor Commented:
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.
0
 
zgreenAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.