How to make sure a batch file is executed properly through a CMD from a c# applicaiton?
<p>I have a c# applications which writes to a batch file and executes it. The application to be started and the path of application will be written in batch file and executed. which is working fine.</p>

<p>How can i make sure that the application launched successfully via my batch file run in command prompt ?</p>

<p>Is there any value that cmd returns after executing a batch file ? or any other ideas please...</p>

<p>Code i am using now : </p>

<pre><code>        public void Execute()
    { 
            string LatestFileName = GetLastWrittenBatchFile();
            if (System.IO.File.Exists(BatchPath + LatestFileName))
            {
                System.Diagnostics.ProcessStartInfo procinfo = new System.Diagnostics.ProcessStartInfo("cmd.exe");
                procinfo.UseShellExecute = false;
                procinfo.RedirectStandardError = true;
                procinfo.RedirectStandardInput = true;
                procinfo.RedirectStandardOutput = true;

                System.Diagnostics.Process process = System.Diagnostics.Process.Start(procinfo);

                System.IO.StreamReader stream = System.IO.File.OpenText(BatchPath + LatestFileName);
                System.IO.StreamReader sroutput = process.StandardOutput;
                System.IO.StreamWriter srinput = process.StandardInput;

                while (stream.Peek() != -1)
                {
                    srinput.WriteLine(stream.ReadLine());
                }

                stream.Close();
                process.Close();
                srinput.Close();
                sroutput.Close();
            }
            else
            {
                ExceptionHandler.writeToLogFile("File not found");
            } 
    }
</code></pre>
