Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Killing running processes on some other machine (over the network) using Delphi?

How can i kill running process on some other machine (over the network) using Delphi?

like image 491
DVDavy Avatar asked Nov 23 '11 11:11

DVDavy


2 Answers

Everything you need can be found at The Road to Delphi, he just blog'd about how to do this on November 6th, check this link WMI Tasks using Delphi – Processes.

like image 194
TDC Avatar answered Sep 28 '22 07:09

TDC


You can use the WTSTerminateProcess API or use Jwscl (Windows Security Library) Terminal Server unit (the TJwWTSProcess class offers a Terminate method).

Small code example:

var 
  TS: TJwTerminalServer;
begin
  TS := TJwTerminalServer.Create('Remote');
  try
    if TS.EnumerateProcess then
    begin
      for i := 0 to TS.Processes.Count -1 do
      begin
        if TS.Processes[i].Name = 'notepad.exe' then
        begin
           TS.Processes[i].Terminate;
        end;
      end;
    end;
  finally
    TS.Free;
  end;
end;
like image 28
Remko Avatar answered Sep 28 '22 07:09

Remko