public static void killProcess(string computerName, string processName) { try { if (ping(computerName)) { ITerminalServer server = new TerminalServicesManager().GetRemoteServer(computerName); server.Open(); server.GetProcesses().First(p => p.ProcessName == processName).Kill(); } } catch { } }
public static List <ITerminalServicesProcess> getComputerProcess(string computerName) { if (ping(computerName)) { ITerminalServer server = new TerminalServicesManager().GetRemoteServer(computerName); server.Open(); List <ITerminalServicesProcess> processes = server.GetProcesses().ToList(); return(processes); } else { return(new List <ITerminalServicesProcess>()); } }
public static void killAnotherCopyOfProgram() { ITerminalServer server = new TerminalServicesManager().GetLocalServer(); server.Open(); var procs = server.GetProcesses().Where( el => el.ProcessName.Equals("rPCSMT.exe") && Process.GetCurrentProcess().Id != el.ProcessId ); foreach (var proc in procs) { proc.Kill(); } }