Launch a batch file, wait until it closes and do something in C# Winforms

I’m working on an application in C# Winforms but I want it to launch a batch file from a specified directory, wait until it closes and do something when closed, like opening another form.

Any help would be highly appreciated.

>Solution :

You can do it in one line:

System.Diagnostics.Process.Start(@"c:\directory\batchfile.bat").WaitForExit();
MessageBox.Show("Batch File execution finished."); 

Leave a Reply