Search code examples
windowstasklisttaskkill

Print all PID from a tasklist command result


I am trying to display all the PID from several processes printed as a result from the tasklist command. Can somebody help me please ?

I also have another issue.When I run the tasklist /FI "Imagename eq javaw.exe" /FI "Windowtitle ne Jenkins*" the result is ok. But when I run taskkill /F /IM javaw.exe "Windowtitle ne Jenkins*" no task is found,but it exist. I also checked taskkill /F /FI "Imagename eq javaw.exe" "Windowtitle ne Jenkins*"

Any ideea why this strage behaviour ?


Solution

  • I figured it out by myself.

    The code bellow print all processes PID from an application (in my case : javaw.exe)

    for /f "tokens=1,2 delims = " %%A in ('tasklist /fi "imagename eq javaw.exe" ^| find ^"javaw^"') do echo %%B

    My seconds question still has no answer yet.