The problem is that the WaitForExit does not wait until the batch file quits. It comes back almost right away.
I'm starting my batch file as follows:
ProcessStartInfo startInfo = new ProcessStartInfo(batchFile);
startInfo.UseShellExecute = true;
startInfo.Arguments = arguments;
using (Process p = Process.Start(startInfo))
{
p.WaitForExit();
}
I tried with and without UseShellExecute
.