0
我怎样才能正确地从runnung vbscript在C#中获取错误输出?从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获得的数据,但如果有脚本错误 - 过程干脆关门,没有消息......
为downvote有何评论? – JleruOHeP 2013-03-25 05:56:13