示例#1
0
 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 { }
 }
示例#2
0
 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>());
     }
 }
示例#3
0
        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();
            }
        }