【发布时间】:2009-12-10 08:38:53
【问题描述】:
我正在使用以下代码调用 PsExec.exe,它在两台服务器中调用我的控制台应用程序,我无法获取被调用进程(我的控制台应用程序)的 ProcessId。
process.StandardOutput.ReadToEnd());只给我服务器名称,而不是完整的内容。
您能帮我获取远程服务器上 PsExec.exe 生成的进程 ID 吗??
Process process = new Process();
ProcessStartInfo psi = new ProcessStartInfo(@"PsExec.exe");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.WindowStyle = ProcessWindowStyle.Minimized;
psi.CreateNoWindow = true;
psi.Arguments = @"-i -u Username -p xxxxxx \\server1,server2 C:\data\GridWorker\GridWorker.exe 100000";
process.StartInfo = psi;
process.Start();
Console.WriteLine(process.StandardOutput.ReadToEnd());
【问题讨论】: