foreach (Process process in System.Diagnostics.Process.GetProcessesByName("myapp")) { try { p.Kill(); p.WaitForExit(); } catch (Win32Exception w32ex) { // process can't be terminated } catch (InvalidOperationException ioex) { // process already exited } catch (Exception ex) { // catch-all for any other exception that might occur } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)