実行できる実際のコードを次に示します。これを行うと、5 つのコンソール ウィンドウがすぐにポップアップして消えることがわかります。
これらのウィンドウをポップアップさせずに stdout/err をリダイレクトするにはどうすればよいですか? 私はいくつかのことを試しましたが、これまでのところ失敗しました。私の実際の使用では、引数が必要で標準入力をリダイレクトする必要がありますが、それはソリューションには影響しません。
[STAThread]
static void Main()
{
for(int i=0;i<5;i++)
{
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = @"C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //doesnt seem to have an effect
process.Start();
process.WaitForExit();
var resO = process.StandardOutput.ReadToEnd();
var resE = process.StandardError.ReadToEnd();
}
}