I have .NET windows form and button. When click on button I start bat file:
//execute batch
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "test.bat";
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(path);
proc.Start();
proc.WaitForExit();
I want to be able to click on button again and stop executing bat. Right now Windows form lose focus and I can't click the button. How can I stop the process from Windows Form?
Thanks