Short solution for short problems

How to kill a process on an other machine?

Found a good solution that does the trick! It takes only 9 line of code!

private void btnKillProcess_Click(object sender, EventArgs e)


ManagementScope scope = new ManagementScope(@"\\MyPCName\root\cimv2");


ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Process WHERE Name = process.exe'");

ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);

ManagementObjectCollection objectCollection = searcher.Get();

foreach(ManagementObject managementObject in objectCollection)


managementObject.InvokeMethod("Terminate", null);



Source: http://weblogs.asp.net/stanleygu/archive/2010/03/31/tip-13-kill-a-process-from-local-to-remote.aspx