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

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#隐藏控制台窗口

posted @ 2022-06-15 14:29  Hey,Coder!  阅读(726)  评论(0编辑  收藏  举报