3

Usual taskkill /im "java.exe" will kill all java processes in the list. I however, want to kill a specific one. The problem is to identify the right process as there are multiple java.exe processes that run simultaneously and not related to each other.

Is there any way to kill a process by application name rather than by process name? I have the application name showing in the Applications tab in Task Manager and manually I can right click on that application and choose "Go To Process". It will highlight the relevant java process. Is there anyway to do it from command line?

5

Using taskkill, you can kill a process based on window title using a filter.

taskkill /F /FI "WindowTitle eq Spotify" /T
  • /F - force task kill
  • /T - Kill child process
  • /FI - Filter the tasks

If the window title has quotes in it, you can escape the nested quotes with a backslash (\).

You can use tasklist in a similar manner to search for a task based on its window title.

tasklist /V /FI "WindowTitle eq Spotify"

You can use the * as a wildcard to match a pattern

tasklist /V /FI "WindowTitle eq S*"
| improve this answer | |
3

For all java.exe processes there is a "Commandline" attribute associated with it which you can get using :

wmic PROCESS where "name like '%java%'" get Commandline

generally you will find Jar file ( specific to java process) as part of the command line

you can use that name of jar file or any part of command line to filer out the java processes and get the desired process id using

wmic PROCESS where "name like '%java.exe%' AND CommandLine like '%<part of commnad line argument>%'"get Processid

instead of using get Processid in above command , you can use call Terminate to directly kill the process.

wmic PROCESS Where "name Like '%java.exe%' AND CommandLine like '%<part of commnad line argument>%'" Call Terminate
| improve this answer | |
  • Thanks I will keep that in mind – Eugene S Jul 5 '19 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.