title: Get already running windows process' console output in a command prompt? Direct StreamReader to command prompt
body: <p>I am trying to determine if there is a way to get the console output, in a command prompt, of an already running process in the windows environment via C#. I have seen <a href="https://stackoverflow.com/questions/30329813/get-outputstream-from-already-running-process">an answer</a> for linux based systems through the shell and also a way to retrieve a <a href="https://stackoverflow.com/questions/17115961/how-to-get-process-object-of-already-running-process"><code>Process</code> object</a>. Though neither offer a solution to get the output of the process.</p>
  
  <p>I my code I currently find a process (MongodDB daemon) this way</p>
  
  <pre><code>Process[] procs = Process.GetProcessesByName("mongod");
  if (procs.Length &gt; 0)
  {
      MongoProcess = procs[0];
      Console.Out.WriteLine("Found mongod.exe, process id: " + MongoProcess.Id);
  }
  </code></pre>
  
  <p>I have also found the <a href="https://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput%28v=vs.110%29.aspx" rel="noreferrer"><code>Process.StandardOutput</code> property</a> which supplies "A StreamReader that can be used to read the standard output stream of the application.". <strong>Is there a way to direct this <code>StreamReader</code> input to a command prompt output?</strong></p>
  
  <p>I also know that I can start a process and display the command prompt (process output), but this is only when the process is started "by me". </p>
  
  <pre><code>Process.Start(new ProcessStartInfo("notepad.exe") { CreateNoWindow = false })
  </code></pre>
  
  <p>I also know that I could simply read from the <code>StreamReader</code> and display the output in my own way, but I would really prefer to just display a command prompt.</p>