Kill a process with a specific “Command Line” from command line
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.
windows command-line process kill
|
show 1 more comment
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.
windows command-line process kill
3
I believe both the answers below are wrong, as you arent just asking how to kill a .exe process, you are asking how to kill a .exe process which contains a specific command line
– admintech
Oct 7 '09 at 10:45
2
Are you only talking about Windows? Your examples and the supplied answers make it seem like you are, but you didn't specify this.
– Nathan Fellman
Oct 7 '09 at 10:45
Can you explain "how this is possible through Process Explorer?" I just launched a java - jar<app-name> and it shows only java.exe
– Sathyajith Bhat♦
Oct 7 '09 at 12:00
i bet he/she meant "sysinternals process explorer"
– akira
Oct 7 '09 at 12:35
Sysinternals Process Explorer, of course. You can view much information about running processes from it, including their command line.
– ripper234
Oct 7 '09 at 14:22
|
show 1 more comment
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.
windows command-line process kill
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.
windows command-line process kill
windows command-line process kill
edited Jan 16 '17 at 22:45
ripper234
asked Oct 7 '09 at 10:16
ripper234ripper234
4,4083073105
4,4083073105
3
I believe both the answers below are wrong, as you arent just asking how to kill a .exe process, you are asking how to kill a .exe process which contains a specific command line
– admintech
Oct 7 '09 at 10:45
2
Are you only talking about Windows? Your examples and the supplied answers make it seem like you are, but you didn't specify this.
– Nathan Fellman
Oct 7 '09 at 10:45
Can you explain "how this is possible through Process Explorer?" I just launched a java - jar<app-name> and it shows only java.exe
– Sathyajith Bhat♦
Oct 7 '09 at 12:00
i bet he/she meant "sysinternals process explorer"
– akira
Oct 7 '09 at 12:35
Sysinternals Process Explorer, of course. You can view much information about running processes from it, including their command line.
– ripper234
Oct 7 '09 at 14:22
|
show 1 more comment
3
I believe both the answers below are wrong, as you arent just asking how to kill a .exe process, you are asking how to kill a .exe process which contains a specific command line
– admintech
Oct 7 '09 at 10:45
2
Are you only talking about Windows? Your examples and the supplied answers make it seem like you are, but you didn't specify this.
– Nathan Fellman
Oct 7 '09 at 10:45
Can you explain "how this is possible through Process Explorer?" I just launched a java - jar<app-name> and it shows only java.exe
– Sathyajith Bhat♦
Oct 7 '09 at 12:00
i bet he/she meant "sysinternals process explorer"
– akira
Oct 7 '09 at 12:35
Sysinternals Process Explorer, of course. You can view much information about running processes from it, including their command line.
– ripper234
Oct 7 '09 at 14:22
3
3
I believe both the answers below are wrong, as you arent just asking how to kill a .exe process, you are asking how to kill a .exe process which contains a specific command line
– admintech
Oct 7 '09 at 10:45
I believe both the answers below are wrong, as you arent just asking how to kill a .exe process, you are asking how to kill a .exe process which contains a specific command line
– admintech
Oct 7 '09 at 10:45
2
2
Are you only talking about Windows? Your examples and the supplied answers make it seem like you are, but you didn't specify this.
– Nathan Fellman
Oct 7 '09 at 10:45
Are you only talking about Windows? Your examples and the supplied answers make it seem like you are, but you didn't specify this.
– Nathan Fellman
Oct 7 '09 at 10:45
Can you explain "how this is possible through Process Explorer?" I just launched a java - jar<app-name> and it shows only java.exe
– Sathyajith Bhat♦
Oct 7 '09 at 12:00
Can you explain "how this is possible through Process Explorer?" I just launched a java - jar<app-name> and it shows only java.exe
– Sathyajith Bhat♦
Oct 7 '09 at 12:00
i bet he/she meant "sysinternals process explorer"
– akira
Oct 7 '09 at 12:35
i bet he/she meant "sysinternals process explorer"
– akira
Oct 7 '09 at 12:35
Sysinternals Process Explorer, of course. You can view much information about running processes from it, including their command line.
– ripper234
Oct 7 '09 at 14:22
Sysinternals Process Explorer, of course. You can view much information about running processes from it, including their command line.
– ripper234
Oct 7 '09 at 14:22
|
show 1 more comment
8 Answers
8
active
oldest
votes
In Windows XP, you can do this easyly uing WMIC, the WMI Console. From a command propt, 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. This alias may not be declared on every OS.
1
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
3
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
add a comment |
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.
add a comment |
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)
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
add a comment |
Simple one-liner in powershell:
(Get-WmiObject win32_process -filter "Name='java.exe' AND CommandLine LIKE '%-jar selenium-server.jar%'").Terminate()
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
add a comment |
Powershell:-
$oProcs = get-process explorer;foreach ($oProc in $oProcs){if ($oProc.Path.Contains('C:Windows')) {Stop-Process $oProc.Id}}
add a comment |
I use a variation of Brain's PowerShell script.
This outputs command line and other info as well.
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'"
foreach($proc in $processes)
{
if($proc.CommandLine.Contains("selenium-server.jar"))
{
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
Stop-Process -F $proc.ProcessId
} else
{
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
}
}
add a comment |
Another powershell variation. It's basically the same, perhaps easier to type and remember. -match can actually take a regular expression.
get-wmiobject win32_process | where commandline -match selenium-server.jar
| remove-wmiobject
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
add a comment |
Use the free PsKill:
pskill java.exe
1
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f52159%2fkill-a-process-with-a-specific-command-line-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
In Windows XP, you can do this easyly uing WMIC, the WMI Console. From a command propt, 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. This alias may not be declared on every OS.
1
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
3
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
add a comment |
In Windows XP, you can do this easyly uing WMIC, the WMI Console. From a command propt, 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. This alias may not be declared on every OS.
1
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
3
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
add a comment |
In Windows XP, you can do this easyly uing WMIC, the WMI Console. From a command propt, 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. This alias may not be declared on every OS.
In Windows XP, you can do this easyly uing WMIC, the WMI Console. From a command propt, 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. This alias may not be declared on every OS.
edited Oct 7 '09 at 13:35
answered Oct 7 '09 at 12:45
BenoitBenoit
57037
57037
1
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
3
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
add a comment |
1
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
3
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
1
1
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
+20 That's it! Dammit :) I too was following the WMIC. But I was doing it from within the WMIC console and wasn't being able to apply LIKE. Was getting syntax errors, which were forcing me to use '=', which in turn forced me to input the whole CommandLine field. Glad to know LIKE works outside the WMIC console. Should have thought of that. Kudos to you
– A Dwarf
Oct 7 '09 at 13:04
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
works perfectly when I call it from command line. I have TeamCity starting a process which I need to kill at the end of the build. Somehow when the same command line called by TeamCity it returns "No Instance(s) Available", the same commad like copied/pasted to cmd kills the process correctly. Any ideas why would that be?
– root
Jun 6 '14 at 14:00
3
3
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
Just a little tip for cmd files - to use this command from cmd file you should replace escape all '%' chars with a second '%' char, e.g. ... CommandLIne Like '%%-jar ...
– sarh
Nov 19 '14 at 16:12
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Oct 7 '09 at 12:44
vpram86vpram86
1,74821316
1,74821316
add a comment |
add a comment |
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)
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
add a comment |
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)
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
add a comment |
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)
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)
edited Oct 7 '09 at 12:25
answered Oct 7 '09 at 12:19
brienbrien
20614
20614
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
add a comment |
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
I tried it with notepad, but the startinfo.arguments were blank.
– js2010
Jan 31 at 17:18
add a comment |
Simple one-liner in powershell:
(Get-WmiObject win32_process -filter "Name='java.exe' AND CommandLine LIKE '%-jar selenium-server.jar%'").Terminate()
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
add a comment |
Simple one-liner in powershell:
(Get-WmiObject win32_process -filter "Name='java.exe' AND CommandLine LIKE '%-jar selenium-server.jar%'").Terminate()
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
add a comment |
Simple one-liner in powershell:
(Get-WmiObject win32_process -filter "Name='java.exe' AND CommandLine LIKE '%-jar selenium-server.jar%'").Terminate()
Simple one-liner in powershell:
(Get-WmiObject win32_process -filter "Name='java.exe' AND CommandLine LIKE '%-jar selenium-server.jar%'").Terminate()
answered Jan 14 '17 at 0:36
wisbuckywisbucky
1,095918
1,095918
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
add a comment |
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
I should really learn PS sometime.
– ripper234
Jan 16 '17 at 22:46
add a comment |
Powershell:-
$oProcs = get-process explorer;foreach ($oProc in $oProcs){if ($oProc.Path.Contains('C:Windows')) {Stop-Process $oProc.Id}}
add a comment |
Powershell:-
$oProcs = get-process explorer;foreach ($oProc in $oProcs){if ($oProc.Path.Contains('C:Windows')) {Stop-Process $oProc.Id}}
add a comment |
Powershell:-
$oProcs = get-process explorer;foreach ($oProc in $oProcs){if ($oProc.Path.Contains('C:Windows')) {Stop-Process $oProc.Id}}
Powershell:-
$oProcs = get-process explorer;foreach ($oProc in $oProcs){if ($oProc.Path.Contains('C:Windows')) {Stop-Process $oProc.Id}}
edited Jun 25 '15 at 20:47
suspectus
3,66161931
3,66161931
answered Jun 25 '15 at 20:16
Richard ForresterRichard Forrester
211
211
add a comment |
add a comment |
I use a variation of Brain's PowerShell script.
This outputs command line and other info as well.
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'"
foreach($proc in $processes)
{
if($proc.CommandLine.Contains("selenium-server.jar"))
{
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
Stop-Process -F $proc.ProcessId
} else
{
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
}
}
add a comment |
I use a variation of Brain's PowerShell script.
This outputs command line and other info as well.
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'"
foreach($proc in $processes)
{
if($proc.CommandLine.Contains("selenium-server.jar"))
{
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
Stop-Process -F $proc.ProcessId
} else
{
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
}
}
add a comment |
I use a variation of Brain's PowerShell script.
This outputs command line and other info as well.
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'"
foreach($proc in $processes)
{
if($proc.CommandLine.Contains("selenium-server.jar"))
{
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
Stop-Process -F $proc.ProcessId
} else
{
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
}
}
I use a variation of Brain's PowerShell script.
This outputs command line and other info as well.
$processes = Get-WmiObject Win32_Process -Filter "name = 'java.exe'"
foreach($proc in $processes)
{
if($proc.CommandLine.Contains("selenium-server.jar"))
{
Write-Host "stopping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
Stop-Process -F $proc.ProcessId
} else
{
Write-Host "skipping proccess $($proc.ProcessId) with $($proc.ThreadCount) threads; $($proc.CommandLine.Substring(0, 50))..."
}
}
edited Mar 20 '17 at 10:17
Community♦
1
1
answered Sep 29 '15 at 11:40
Jan HJan H
16114
16114
add a comment |
add a comment |
Another powershell variation. It's basically the same, perhaps easier to type and remember. -match can actually take a regular expression.
get-wmiobject win32_process | where commandline -match selenium-server.jar
| remove-wmiobject
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
add a comment |
Another powershell variation. It's basically the same, perhaps easier to type and remember. -match can actually take a regular expression.
get-wmiobject win32_process | where commandline -match selenium-server.jar
| remove-wmiobject
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
add a comment |
Another powershell variation. It's basically the same, perhaps easier to type and remember. -match can actually take a regular expression.
get-wmiobject win32_process | where commandline -match selenium-server.jar
| remove-wmiobject
Another powershell variation. It's basically the same, perhaps easier to type and remember. -match can actually take a regular expression.
get-wmiobject win32_process | where commandline -match selenium-server.jar
| remove-wmiobject
edited Feb 1 at 16:57
answered Jan 31 at 17:24
js2010js2010
1863
1863
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
add a comment |
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
Could you explain the difference between your PS command and the others here?
– Burgi
Feb 1 at 16:27
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
It's basically the same. Perhaps easier to type and remember. -match can actually take a regular expression.
– js2010
Feb 1 at 16:32
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
You should edit your answer to include that...
– Burgi
Feb 1 at 16:43
add a comment |
Use the free PsKill:
pskill java.exe
1
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
add a comment |
Use the free PsKill:
pskill java.exe
1
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
add a comment |
Use the free PsKill:
pskill java.exe
Use the free PsKill:
pskill java.exe
edited Jan 31 at 20:22
community wiki
2 revs
harrymc
1
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
add a comment |
1
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
1
1
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
you missed the 2nd part of the question: "specific commandline"... not the first java.exe, that comes along .. neither all java.exe processes
– akira
Oct 7 '09 at 11:33
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f52159%2fkill-a-process-with-a-specific-command-line-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
I believe both the answers below are wrong, as you arent just asking how to kill a .exe process, you are asking how to kill a .exe process which contains a specific command line
– admintech
Oct 7 '09 at 10:45
2
Are you only talking about Windows? Your examples and the supplied answers make it seem like you are, but you didn't specify this.
– Nathan Fellman
Oct 7 '09 at 10:45
Can you explain "how this is possible through Process Explorer?" I just launched a java - jar<app-name> and it shows only java.exe
– Sathyajith Bhat♦
Oct 7 '09 at 12:00
i bet he/she meant "sysinternals process explorer"
– akira
Oct 7 '09 at 12:35
Sysinternals Process Explorer, of course. You can view much information about running processes from it, including their command line.
– ripper234
Oct 7 '09 at 14:22