title: Command prompt output being read as empty string
body: <p>I'm trying to execute command prompt commands and read the output in C#. This is my code:</p>
  
  <pre><code>ProcessStartInfo cmdInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
  cmdInfo.CreateNoWindow = true;
  cmdInfo.RedirectStandardOutput = true;
  cmdInfo.UseShellExecute = false;
  
  Process cmd = new Process();
  cmd.StartInfo = cmdInfo;
  cmd.Start();
  string result = cmd.StandardOutput.ReadToEnd();
  cmd.WaitForExit();
  cmd.Close();
  return result;
  </code></pre>
  
  <p>It works most of the time, but sometimes result="" when that's impossible for the command I'm using (for example, route add should give output on success or failure). Any ideas? I was wondering if maybe I'd created a race condition between the process and the ReadToEnd call?</p>