Reputation: 93
I'm running an app A and it starts another app B using process start. Is it possible for me to get the trace information of app B?
Upvotes: 1
Views: 868
Reputation: 171784
You can capture StandardOutput. From the MSDN documentation:
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
So by reading StandardOutput
(and/or StandardError
) you can capture the output of a process you just launched.
Upvotes: 1