Monday, December 1, 2014

Kill task in windows from command line

1. Bring out an command line terminal
cmd












2. Useful command about "tasklist"
tasklist /?
tasklist /fo list
tasklist /fo table
tasklist /fo csv
tasklist /fi "imagename eq firefox.exe" 

tasklist /F /fi "imagename eq firefox.exe"           ## force to kill task

3. Useful command man page about "taskkill"
taskkill /?






4. Examples 

4.1) Use filter to find the application you want to terminate. 
C:\Users\dxu>tasklist  /fi  "imagename eq firefox.exe"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
firefox.exe                   7804 Console                    1    135,052 K
4.2) Kill the application by PID
C:\Users\dxu>taskkill /pid 7804
SUCCESS: Sent termination signal to the process with PID 7804.

C:\Users\dxu>tasklist  /fi  "imagename eq firefox.exe"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
firefox.exe                  11584 Console                    1    115,612 K


4.3) Force to kill application "/f"
C:\Users\dxu>taskkill /f /im firefox                    ## Must specify full imagename.
ERROR: The process "firefox" not found.



C:\Users\dxu>taskkill /f /im firefox.exe
SUCCESS: The process "firefox.exe" with PID 11584 has been terminated.

No comments:

Post a Comment