title: Redirect input and output for cmd.exe
body: <p>I wanna redirect cmd.exe output somewhere, below code works when the command is a line:</p>
  
  <pre><code>Process p = new Process()
  {
      StartInfo = new ProcessStartInfo("cmd")
      {
         UseShellExecute = false,
         RedirectStandardInput = true,
         RedirectStandardOutput = true,
         CreateNoWindow = true,
         Arguments = String.Format("/c \"{0}\"", command),
      }
  };
  p.OutputDataReceived += (s, e) =&gt; Messagebox.Show(e.Data);
  p.Start();
  p.BeginOutputReadLine();
  p.WaitForExit();
  </code></pre>
  
  <p>But how about a series commands like WriteLine():</p>
  
  <pre><code>p.StandardInput.WriteLine("cd...");
  p.StandardInput.WriteLine("dir");
  </code></pre>
  
  <p>how to get output in this situation?</p>