如何启动隐藏的进程

本文关键字:隐藏 进程 启动 何启动 | 更新日期: 2023-09-27 18:03:42

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

Try This:

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

Try

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