[英]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. 如何在C#中运行批处理文件,但在没有显示命令提示符窗口的背景中运行。
I use this Process.Start(batch.bat"); but this will display the command prompt. 我使用这个Process.Start(batch.bat“);但是这将显示命令提示符。
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: 您可以使用Startinfo指定:
var si = new System.Diagnostics.ProcessStartInfo();
si.CreateNoWindow = true;
si.FileName = "test.cmd";
System.Diagnostics.Process.Start( si);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.