Windows Command Line – How to Kill a Process with Specific Command Line

command linekillprocesswindows

Is there a command line utility that kills all processes with a specific command line?

E.g. kill all processes named "java.exe" with a command line that contains "-jar selenium-server.jar". This is possible through process explorer.

Best Answer

In Windows XP you can do this easily using WMIC, the WMI Console. From a command prompt, type the following:

wmic Path win32_process Where "CommandLine Like '%-jar selenium-server.jar%'" Call Terminate

Edit:

I replaced the alias 'process' by it full path ('path win32_process') as is Aviator's port. Note: This alias may not be declared on every OS.