tags:

views:

20

answers:

2

From the command line, I can list tasks on a remote machine like this:

c:\>tasklist /s some_machine /u admin_user /p admin_user_password

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0                            0         16 K
System                           4                            0        236 K
svchost.exe                    632                            0      3,328 K
svchost.exe                    700                            0      4,660 K
svchost.exe                    776                            0     38,664 K

And I can kill them like this:

c:\>taskkill /s some_machine /im notepad.exe /f /u admin_user /p admin_password
SUCCESS: The process "notepad.exe" with PID 1828 has been terminated.

How can I do this using Win32 API calls? I'm trying to implement this in Delphi, but I am happy to translate an example from another language.

I've been looking at EnumProcesses, which works great for a local machine, but does not seem to support remote connections.

A: 

You should be able to do this via WMI.

Joey
A: 

Looks like you can do it with WMI. Specifically, Win32_Process.Terminate.

Matthew Flaschen