Return to Snippet

Revision: 59724
at September 26, 2012 23:00 by Verician


Initial Code
public static void stopNamedProcess(string name)
        {
            foreach (Process p in System.Diagnostics.Process.GetProcessesByName(name))
            {
                try
                {
                    p.Kill();
                    p.WaitForExit(); 
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                    System.Diagnostics.EventLog.WriteEntry("AlchemySearch:KillProcess", exp.Message, System.Diagnostics.EventLogEntryType.Error);
                }

            } 

        }

Initial URL


Initial Description
I built a middleware app to fire from an ERP addon, as part of the trigger process my app needed to close the ERP addon to reduce errors during a re-run of the event. I used this to kill the process.

Initial Title
Kill Named Process C#

Initial Tags


Initial Language
C#