title: How to get the error code and its description of a process
body: <p>How do I check whether the process executed successfully in C# code? Below is the code I used to check. Is it enough to check <code>p.ExitCode = 0</code> for successful execution? If it is so, then how do I get the description of the error if I get any error, (i.e) <code>ExitCode &lt;&gt; 0</code>?</p>
  
  <pre><code>ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", "/c " + command);
  psi.RedirectStandardOutput = false;
  psi.RedirectStandardError = false;
  psi.UseShellExecute = true;
  psi.CreateNoWindow = true;
  psi.WindowStyle = ProcessWindowStyle.Hidden;
  
  Process p = new Process();
  p.StartInfo = psi;
  p.Start();
  p.WaitForExit();
  
  MessageBox.Show("Error Code:" + p.ExitCode);
  </code></pre>