C# Process Killing

Moon picture Moon · Feb 10, 2010 · Viewed 34.4k times · Source

I need to write a program in c# that would just start, kill one process\exe that it is supposed to kill and end itself.

The process I need to kill is another C# application so it is a local user process and I know the path to the exe.

Answer

SwDevMan81 picture SwDevMan81 · Feb 10, 2010

Check out Process.GetProcessesByName and Process.Kill

// Get all instances of Notepad running on the local
// computer.
Process [] localByName = Process.GetProcessesByName("notepad");
foreach(Process p in localByName)
{
   p.Kill();
}