c# 启动外部命令 隐藏窗口

阅读 68

2022-07-28

ProcessStartInfo.UseShellExecute 属性需要设置为true

Process proc = new Process();
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();
proc.WaitForExit();

[参考]
​​​ProcessStartInfo.UseShellExecute 属性​​​​从Process.Start C#隐藏控制台窗口​​


精彩评论(0)

0 0 举报