Windows tasklist and findstr, playing with the command line
Posted by gr8dude on 2007 Sep 25, Tue in Technology / programming
A short story, so that I don't forget... about the Windows equivalent of ps and grep and kill.
- tasklist - display a list of processes that are currently running on the system
- findstr - search a string in a given file or text excerpt
- taskkill - terminate a running process
Examples of use:
tasklist | findstr -ir \svchost
svchost.exe 1212 Console 0 1.672 K
svchost.exe 1292 Console 0 1.748 K
svchost.exe 1408 Console 0 13.812 K
svchost.exe 1640 Console 0 1.316 K
svchost.exe 1712 Console 0 4.312 K
svchost.exe 3904 Console 0 1.860 K
svchost.exe 2256 Console 0 3.440 KThis would look like ps -ef | grep svchost* in the *NIX world; though I expect you'd find no processes called svchost ;-)
There is also taskkill, that can terminate a process, ex:
taskkill /F /IM explorer.exe /T