sessionista
sessionista

Reputation: 93

Can you get trace output from a process that was started within another application in C#?

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

Answers (1)

Philippe Leybaert
Philippe Leybaert

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

Related Questions