Mark
Mark

Reputation:

how to run batch file from C# in the background

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

Answers (3)

Mark
Mark

Reputation:

  ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
  si.CreateNoWindow = true;
  si.FileName = "setSecDLL.bat";
  si.UseShellExecute = false;
  System.Diagnostics.Process.Start(si);

Upvotes: 10

Henk Holterman
Henk Holterman

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

aquinas
aquinas

Reputation: 23796

Process p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

Upvotes: 15

Related Questions