私の場合、別のプロセスを開始して Exited イベントをサブスクライブするプロセスがあります。最後の 2 番目のプロセスは、エラー文字列を何らかの方法で最初のプロセスに渡す必要があります。最初のプロセスでは、画面にメッセージが表示されます。
別のアプリが文字列を読み取って表示できるように、アプリケーションの最後に文字列を渡す方法は?
StandardError ストリームをリダイレクトできます: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror.aspx
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("net ","use "+ args[0]);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardError = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardError;
// Read the standard error of net.exe and write it on to console.
Console.WriteLine( myStreamReader.ReadLine());
myProcess.Close();
以下を調べて、シナリオに最も適したものを選択してください。私の推測では、データを親プロセスに戻す場合は、出力またはエラーが必要です。
StartInfo.RedirectStandardOutput
StartInfo.RedirectStandardError
StartInfo.RedirectStandardInput