Run commands and wait for completion in c#
<p>I need to do this in my c# program.</p>

<pre><code>           Process process = LaunchCommandWindow("Special args and environment set")
           process.StandardInput.WriteLine("cmd1");
           process.StandardInput.WriteLine("cmd2");

           //Parse logs
            using (Streamreader sr =  new ())
           { etc etc..}
</code></pre>

<p>My commands execute correctly, but the problem is that Parse logs code doesnt wait for cmd1 and cmd2 execution to complete. I cannot call exit and  process. waitforexit because, after parsing the logs, I have more commands to execute.</p>

<p>Here is how process start info is set. LaunchCommandWindow()</p>

<pre><code>         ProcessStartInfo startInfo = new ProcessStartInfo();

        startInfo.FileName = Path.Combine(Environment.SystemDirectory, "cmd.exe");
        startInfo.Arguments = "/K " + newEnvironmentArgs;

        startInfo.UseShellExecute = false; 
        startInfo.RedirectStandardInput = true;
        Process process = new Process();
        process.StartInfo = startInfo;
        process.Start();

        return process;
</code></pre>

<p>How do I get the parse logs code to wait for cmd2 completion?</p>

<p>Thanks.</p>
