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 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 page. Any ideas?

Is there a better forum for my question?

StreamReader sr = null;
ProcessStartInfo psi = null; 
try {
psi = new ProcessStartInfo("cmd.exe", "ping");
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);
sr = p.StandardOutput; 
//put output to message
lblMessage.Text = "Result: " + sr.ReadToEnd();
} catch (Exception ex) {
lblMessage.Text = ex.Message;

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:

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.
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.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

From the code, he appears to be trying to perform a "ping".

zgreenAuthor Commented:
I am trying to successfully execute the code above on server 2008 IIS 7.
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.
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zgreenAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.