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.
So the impersonation suggestions were interesting, but ultimately my problem was with my console app itself. It was trying to write some log files to the user’s application data directory (even with the
-silentoption…), which I wasn’t expecting.Removing those pieces (thus making it adhere to the
-silentcommand) made everything work perfectly