使用PsExec.exe(sysinternals)启动进程时读取StandardOutput

时间:2012-09-11 23:48:03

标签: c# .net

我使用PsExec.exe在远程计算机上调用exe。 远程计算机中的exe执行某些操作并在控制台中显示输出。 一切正常,直到我尝试重定向输出。代码如下,

ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = "PsExec.exe";
processInfo.Arguments = "\\\\servername \"C:\\PROGRA~1\\myapp\\app.exe\"";
processInfo.RedirectStandardOutput = true;
processInfo.UseShellExecute = false;
using (Process process = Process.Start(processInfo))
{
string outPutString = process.StandardOutput.ReadToEnd();
}

process.StandardOutput.ReadToEnd()挂起并且什么都不做。 那么,如何在使用PsExec.exe启动进程时读取StandardOutput?

0 个答案:

没有答案