I
ice9
I seem to be missing something in this straightforward example.. but i
have a vbs file that is now simplified to one line:
Wscript.Echo "test"
When i run the process, i'd like output to be returned asynchronously
since i will be running this script many times with differetn
parameters and collecting return strings.
my return "test" text actually work in synchronous mode:
process.StandardOutput.ReadToEnd()
however in the following example, ( inside a webservice method ), the
OutputDataReceived never fires:
Process p = new Process();
p.OutputDataReceived += new
DataReceivedEventHandler(p_OutputDataReceived);
p.ErrorDataReceived += new
DataReceivedEventHandler(p_ErrorDataReceived);
p.StartInfo.FileName = @"c:\windows\system32\cscript.exe";
p.StartInfo.Arguments = @"c:\test.vbs";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
// this works
// Process.Start(triggerPaths);
}
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e) {
string s = e.Data.ToString();
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e) {
// never fires
string s = e.Data.ToString();
}
have a vbs file that is now simplified to one line:
Wscript.Echo "test"
When i run the process, i'd like output to be returned asynchronously
since i will be running this script many times with differetn
parameters and collecting return strings.
my return "test" text actually work in synchronous mode:
process.StandardOutput.ReadToEnd()
however in the following example, ( inside a webservice method ), the
OutputDataReceived never fires:
Process p = new Process();
p.OutputDataReceived += new
DataReceivedEventHandler(p_OutputDataReceived);
p.ErrorDataReceived += new
DataReceivedEventHandler(p_ErrorDataReceived);
p.StartInfo.FileName = @"c:\windows\system32\cscript.exe";
p.StartInfo.Arguments = @"c:\test.vbs";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
// this works
// Process.Start(triggerPaths);
}
void p_ErrorDataReceived(object sender, DataReceivedEventArgs e) {
string s = e.Data.ToString();
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e) {
// never fires
string s = e.Data.ToString();
}