Reputation:
How can I run a batch file from C# but in the backgound without the command prompt windows being displayed.
I use this Process.Start(batch.bat"); but this will display the command prompt.
Any idea?
Upvotes: 2
Views: 11726
Reputation:
ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
si.CreateNoWindow = true;
si.FileName = "setSecDLL.bat";
si.UseShellExecute = false;
System.Diagnostics.Process.Start(si);
Upvotes: 10
Reputation: 273274
You can specify that with a Startinfo:
var si = new System.Diagnostics.ProcessStartInfo();
si.CreateNoWindow = true;
si.FileName = "test.cmd";
System.Diagnostics.Process.Start( si);
Upvotes: 2
Reputation: 23796
Process p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Upvotes: 15