Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing an EXE from ASP.NET

Tags:

c#

asp.net

iis-6

I'd like to execute an exe from an ASP.NET MVC application. Yes I understand that inherent risks of doing this, but unfortunately I really need to do it.

The EXE is a GUI application, but the arguments I pass it force it to run "silently" where it generates some data into a zip file and then quits.

The code to execute the EXE is as follows -- it runs fine in VS2008 on my development box -- but when I test against the actual server (Server 2003 - IIS6), it fails:

        ProcessStartInfo psi = new ProcessStartInfo();
        psi.FileName = "C:\.....";
        psi.Arguments = "-silent -file outFile.zip";

        Process proc = new Process();
        proc.StartInfo = psi;
        proc.Start();

        proc.WaitForExit();
        log.Debug("Process exited: " + proc.ExitCode);

The exit code is: -532459699, so something obviously went wrong.

I am running the application on the server over an authenticated HTTPS connection (basic authentication), so I thought I'd be able to get around the problem by setting <identity impersonate="true" /> in the Web.config file under the <system.web> tag. But -- that hasn't worked.

Thanks -- all help is appreciated.

like image 817
debracey Avatar asked May 20 '26 20:05

debracey


1 Answers

Your web site runs under a restricted user account. Your EXE will run under the same restricted account unless you use impersonation.

Edit: support from Microsoft: http://support.microsoft.com/kb/306158

like image 66
Adi Avatar answered May 22 '26 12:05

Adi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!