title: System.Diagnostics.Process takes more time compared to command prompt
body: <p>I am trying to mount VHD file from inside c# code using System.Diagnostics.Process to execute diskpart.exe command.</p>
  
  <p>Below is code snippet that i use:</p>
  
  <pre><code>        process.StartInfo.FileName = "diskpart.exe";
          process.StartInfo.UseShellExecute = false;
          process.StartInfo.CreateNoWindow = true;
          process.StartInfo.RedirectStandardOutput = true;
          process.StartInfo.RedirectStandardError = true;
          process.StartInfo.RedirectStandardInput = true;
  
          process.Start();
          StreamWriter writer = process.StandardInput;
  
          writer.Write("select vdisk file=" + vhdfile + System.Environment.NewLine);
          writer.Write("attach vdisk" + System.Environment.NewLine);
          writer.Write("online disk" + System.Environment.NewLine);
          writer.Write("select part 1" + System.Environment.NewLine);
          writer.Write("remove all" + System.Environment.NewLine);
          writer.Write("assign mount=" + mountpoint + System.Environment.NewLine);
  
          writer.Close();
  
          process.WaitForExit();
          process.Close();
  </code></pre>
  
  <p>The problem is if i execute the same command in command prompt (using batch file), it takes around 0.5 second to execute. But if i run the above code, it takes around 5 seconds for WaitForExit() to return.</p>
  
  <p>I tried setting RedirectStandardOutput and RedirectStandardError both true and false but i see no difference.</p>
  
  <p>Please let me know what i might be doing wrong here.</p>
  
  <p>Thanks.</p>