简体   繁体   中英

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?

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM