I have a dot net MVC 4 application in which I user creates a request using “create” view and based on the params from view, the controller should execute windows batch scripts asynchronously.
I’m using following code to run the batch script:
Process process = new Process();
ProcessStartInfo ProcessInfo;
ProcessInfo = new ProcessStartInfo("cmd", "/c batchfile");
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = false;
ProcessInfo.RedirectStandardError = true;
ProcessInfo.RedirectStandardOutput = true;
ProcessInfo.Arguments = string.Format("{0} {1} {2}", arg1, arg2, arg3); ;
process = Process.Start(ProcessInfo);
process.WaitForExit();
The console app process is started but it always hangs/waits endlessly. The standard output logs show:
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\IIS Express>
The process exits only when I manually kill it. I tried running Visual Studio administrator mode but it didn’t help.
Can anyone please suggest how I can get around this?
Here’s a reference article about command line parameters passed to
cmd.exeI would recommend you checking.Then try like this: