■ 終了コードを得るには
* Process.ExitCode から取得するAPI仕様 Process.ExitCode
https://docs.microsoft.com/ja-jp/dotnet/api/system.diagnostics.process.exitcode?view=netframework-4.8
例
Process process = new Process(); process.StartInfo.FileName = @"C:\hello.exe"; process.Start(); process.WaitForExit(); // ★ここ Process.ExitCode ★ int exitCode = process.ExitCode;
参考文献
https://www.atmarkit.co.jp/fdotnet/dotnettips/858procexitcode/procexitcode.html■ 標準出力・標準エラーを得るには
* Process.StandardOutput.ReadToEnd() / Process.StandardOutput.ReadToEnd() から取得するAPI仕様 Process.StandardOutput
https://docs.microsoft.com/ja-jp/dotnet/api/system.diagnostics.process.standardoutput?view=netframework-4.8
API仕様 Process.StandardError
https://docs.microsoft.com/ja-jp/dotnet/api/system.diagnostics.process.standarderror?view=netframework-4.8
例
Process process = new Process(); process.StartInfo.FileName = @"C:\hello.exe"; //出力とエラーをストリームに書き込むようにする process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.Start(); // ★ ここ ★ string standardOutput = process.StandardOutput.ReadToEnd(); string standardError = process.StandardError.ReadToEnd(); process.WaitForExit();
参考文献
https://dobon.net/vb/dotnet/process/standardoutput.html■ 非同期実行
参考文献
https://www.atmarkit.co.jp/fdotnet/dotnettips/805pipeasync/pipeasync.htmlhttps://akamist.com/blog/archives/1195
https://qiita.com/kazu3516/items/f692fbd6da7c056c7c3b