Friday, July 4, 2014

Kill all processes with name wildcard via wmic

Logon as user with administrator privileges then: 
wmic process where "name like '%<application name>%'" delete

E.g. To kill all VNC server processes
$ wmic process where "name like 'vncserv%'" delete
Deleting instance \\IDEA-PC\ROOT\CIMV2:Win32_Process.Handle="1976"
Instance deletion successful.
Deleting instance \\IDEA-PC\ROOT\CIMV2:Win32_Process.Handle="1088"
Instance deletion successful.
Deleting instance \\IDEA-PC\ROOT\CIMV2:Win32_Process.Handle="3212"
Instance deletion successful.

Or you can use SSH to kill processes remotely on a windows box from *nix box:

ssh <user>@<ip address> $(echo wmic process where \"name like \'%<process to kill>%\'\" delete)

or
 
ssh <user>@<ip address> taskkill /f /im <process to kill> /t 

No comments:

Post a Comment