我通过ProcessStartInfo和process.Start()启动控制台应用程序。我想隐藏黑色的窗户。这是我的代码:
string output = "";
//Setup the Process with the ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\\WINNT\\system32\\cmd.exe";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
//Start the process
Process proc = Process.Start(startInfo);
答案 0 :(得分:31)
最终答案是
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = ....
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = false;
psi.Arguments =...
psi.UseShellExecute = false;
<强> psi.CreateNoWindow = true; // <- key line
强>
答案 1 :(得分:29)
试试这个:
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
答案 2 :(得分:7)
尝试
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
答案 3 :(得分:2)
Process p = new Process();
....
p.StartInfo.CreateNoWindow = true;
p.Start();