Kill a process with a specific "Command Line" from command line
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Kill A Process With A Specific &Quot;Command Line&Quot; From Command Line
00:25 Answer 1 Score 3
00:44 Answer 2 Score 9
01:07 Accepted Answer Score 40
01:34 Answer 4 Score 2
01:43 Thank you
--
Full question
https://superuser.com/questions/52159/ki...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline #process #kill
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Kill A Process With A Specific &Quot;Command Line&Quot; From Command Line
00:25 Answer 1 Score 3
00:44 Answer 2 Score 9
01:07 Accepted Answer Score 40
01:34 Answer 4 Score 2
01:43 Thank you
--
Full question
https://superuser.com/questions/52159/ki...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline #process #kill
#avk47
ACCEPTED ANSWER
Score 40
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.
ANSWER 2
Score 9
If you are using a Windows version which has WMIC command in it. You can try this
wmic path win32_process Where "Caption Like '%java.exe%' AND CommandLine Like '%selenium.jar%'" get ProcessId|more +1
The more +1
removes first line containing the header and prints the PID alone. If there are more than one java process containing selenium.jar then this will return one PID per line.
ANSWER 3
Score 3
I believe you could do this with PowerShell using Get-Process and the StartInfo.Arguments on the process you want.
$procs = Get-Process java
foreach($proc in $procs)
{
if($proc.StartInfo.Arguments -contains "-jar selenium-server.jar")
{
kill $proc
}
}
(I haven't tested that completely, but you should be able to tweak it to make it work)
ANSWER 4
Score 2
Powershell:-
$oProcs = get-process explorer;foreach ($oProc in $oProcs){if ($oProc.Path.Contains('C:\Windows')) {Stop-Process $oProc.Id}}