Kill a process remotely using asp.net

sencor

New Member
please help me as i need to kill/ restart a process remotely.I have tried this but no luck for me. Error was - "Couldn't connect to remote machine"\[code\]Process[] prs = Process.GetProcesses("SERVERNAME"); foreach (Process pr in prs) { if (pr.ProcessName == "process") { pr.Kill(); } }\[/code\]I also try this one but still doesn't work and got this error: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"\[code\]ManagementScope scope = new ManagementScope("\\\\SERVERNAME\\root\\cimv2");scope.Connect();ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Process WHERE Name='process'");ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);ManagementObjectCollection objectCollection = searcher.Get(); foreach (ManagementObject managementObject in objectCollection) { managementObject.InvokeMethod("Terminate", null); }\[/code\]I hope someone has a solution for this.Thanks in advance!
 
Back
Top