0

リモート サーバー上にある .exe を実行していますが、PsExec がハングしたように見え、ローカル サービスが終了しません。.exe はサーバー上で正常に実行されますが、終了したらローカル サービスを終了します。

これは私が持っているコードです:

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();

リモート サービスが終了したときにローカル サービスを終了するにはどうすればよいですか?

4

2 に答える 2

0

非対話型アプリケーションに推奨される -d オプションを指定して psexec を実行してみてください。または、psexec でタイムアウト オプションを設定できますか?

于 2013-06-28T14:48:29.223 に答える
0

試しました p.WaitForInputIdle();か?

- - - - - - - アップデート

GUI/非 GUI の違い:プロセスにグラフィカル インターフェイスがあるかどうかを確認するにはどうすればよいですか?

于 2013-06-28T14:33:39.577 に答える