Hi fellow software developers
So I need to start a CMD process in my .NET MVC web project. This is my function that I pass the command I need to call:
private void ExecuteCommandSync(string command)
{
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
// Hide the CMD window:
procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// The following commands are needed to redirect the standard output.
procStartInfo.UseShellExecute = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
}
The command calls a program that starts a linear programming framework that solves a problem which takes 20 seconds to finish.
The problem is that nothing happens when this function is called! It works fine outside the IIS, but not in IIS. The IIS web server runs on a Windows Server 2012. My web project is called from outside of our local network, where the web server is running, does some work, calls my synchronous method and waits for it to finish and ends by returning the result of the call as a JSON object.
This question suggests that it might have something with user privileges. In the Application Pools for the web project in Advanced Settings -> Identity I have tried to change from ApplicaitonPoolIdentity to Local System (which has high privileges) but no luck (as explained here).
Does anyone have any suggestions to how I can solve this problem? Any advice would be greatly appreciated.