在我正在处理的应用程序中,一切都很好。我的问题是,有没有办法在执行psexec时压缩命令窗口?我希望它能够静静地运行。下面是我使用的代码..我在网上阅读了很多例子,但似乎没有任何工作。思考?谢谢。禁止psexec命令窗口?
Process p = new Process();
try
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p = Process.Start(psExec, psArguments);
if (p != null)
{
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
if (p != null)
{
p.Dispose();
}
}
正在运行什么进程?如果这个过程有一个可以被抑制的主窗口,它通常是......但是如果它产生了随机窗口,那么你可以做的事情就不多了。 – Vlad
我正在做几件事情。网络使用,出口regKeys等。每次,它开启一个新窗口。 – Sparhawk