title: C# Process exit on batch file status?
body: <pre><code>static void Main(string[] args) 
  {
      Process process=Process.Start(@"C:\Users\dalvi\Desktop\iisresetdaily.bat");
  
      if(process.ExitCode==0)
          SendMail("Sucesss in iisreset..", "bye"); // --&gt; case 1
      else
          SendMail("Failed iisreset..", "bye"); // --&gt; case 2
  }
  </code></pre>
  
  <p>Edit : My <code>SendMail</code> method is working fine. </p>
  
  <p>I've written <code>iisresetdaily.bat</code> file which is doing <code>iisreset /stop</code> and <code>iisreset /start</code>. When it executes successfully, I need to send success in <code>iisrest</code> mail <code>--&gt; case 1</code>, otherwise 
  <code>case 2</code>. </p>
  
  <p>But when I edit the <code>.bat</code> file and put some random words so batch file is failing, but still
  it's sending <code>case 1</code> mail meaning success in <code>iisreset</code>. </p>
  
  <p>Am I doing wrong to check status of batch file using Process.ExitCode here? </p>
  
  <p>If batch file failed, I need to send <code>case 2</code> failed <code>iisreset</code>. </p>