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