• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1758
  • Last Modified:

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

0
zgreen
Asked:
zgreen
  • 4
  • 3
  • 2
1 Solution
 
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
 
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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
 
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
 
zgreenAuthor Commented:
Thanks.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now