C#でrunnung vbscriptからエラー出力を正しく取得するにはどうすればよいですか?
これが私のコードです:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = new System.Diagnostics.ProcessStartInfo("cscript");
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.OutputDataReceived += (proc, outLine) => MessageBox.Show(outLine.Data,
"Data:",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
p.ErrorDataReceived += (proc, outLine) => MessageBox.Show(outLine.Data,
"error!",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
p.StartInfo.Arguments = "C:\\test.vbs";
p.Start();
p.BeginOutputReadLine();
このようにして、cscriptからデータを取得できますが、スクリプトにエラーがある場合、プロセスはメッセージなしで単に閉じられます...