我正在执行一个位于远程服务器上的 .exe,但是 PsExec 似乎挂起并且本地服务没有退出。.exe 确实在服务器上成功运行,但是完成后我希望本地服务退出。
这是我有atm的代码:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.FileName = @"C:\Program Files (x86)\PSTools\PsExec.exe";
p.StartInfo.Arguments = @"\\<remote .exe path>";
p.Start();
//I have tried the following to exit the local service when a response is
//received but it still hangs.
//string output = p.StandardOutput.ReadToEnd();
//string errormessage = p.StandardError.ReadToEnd();
//p.WaitForExit();
远程服务完成后,我需要做什么才能退出本地服务?