What is the right Windows API call to view and kill a task on a remote computer?
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 开发者_StackOverflow中文版 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.
You should be able to do this via WMI.
Looks like you can do it with WMI. Specifically, Win32_Process.Terminate.
精彩评论