如何启动进程隐藏?

我通过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); 

最后的答案是

  ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = .... psi.RedirectStandardInput = true; psi.RedirectStandardOutput = false; psi.Arguments =... psi.UseShellExecute = false; 

psi.CreateNoWindow = true; // <- key line

试试这个:

 startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 

尝试

 startInfo.WindowStyle = ProcessWindowStyle.Hidden; 
 Process p = new Process(); .... p.StartInfo.CreateNoWindow = true; p.Start();