Steve Lamb's Blog

Security Matters

Blogs

How to list running processes and kill them via the command line

  • Comments 7
  • Likes

Thanks to James for letting me know that there's an easy way to list and kill processes from the Windows Vista command line.

Back in the days (pre-Microsoft) when I was an UNIX network administrator I often used the command "ps -ef" to list the running processes.Task Manager on Windows gets the job done but somehow doesn't feel quite right to me. Eurka - Windows Vista provides the commands "tasklist" and "taskkill". Such commands will be handy for use in scripts of course too.

The following extract is from a Windows shell session to show you the interface:

E:\Users\stephlam>tasklist

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0                            0         16 K
System                           4                            0        900 K
smss.exe                       408                            0        524 K
csrss.exe                      468                            0      4,868 K
wininit.exe                    508                            0      2,808 K
csrss.exe                      548 Console                    1     12,052 K
services.exe                   564                            0      4,296 K
lsass.exe                      576                            0      2,568 K
lsm.exe                        584                            0      3,104 K
winlogon.exe                   644 Console                    1      3,832 K
svchost.exe                    780                            0      4,732 K
svchost.exe                    848                            0      5,720 K
svchost.exe                    876                            0      7,872 K
LogonUI.exe                    916 Console                    1      9,692 K
svchost.exe                    976                            0      8,644 K
svchost.exe                   1000                            0     23,836 K
SLsvc.exe                     1040                            0      3,944 K
svchost.exe                   1064                            0      8,708 K
svchost.exe                   1256                            0      2,280 K
svchost.exe                   1308                            0     48,900 K
svchost.exe                   1336                            0     11,176 K
wisptis.exe                   1376 Console                    1      4,592 K
spoolsv.exe                   1528                            0      7,416 K
audiodg.exe                   1596                            0      7,144 K
svchost.exe                   1616                            0      7,092 K
inetinfo.exe                  2024                            0      4,572 K
InoRpc.exe                     320                            0      3,572 K
InoRT.exe                      540                            0      8,396 K
InoTask.exe                    832                            0      6,348 K
svchost.exe                   1740                            0      3,960 K
svchost.exe                   1768                            0      2,240 K
SRUserService.exe              956                            0      4,488 K
svchost.exe                   1964                            0      4,184 K
vmh.exe                       1808                            0      2,744 K
svchost.exe                   2060                            0      3,680 K
svchost.exe                   2072                            0      2,056 K
SearchIndexer.exe             2096                            0     38,236 K
WUDFHost.exe                  2200                            0      3,512 K
CcmExec.exe                   2276                            0     13,056 K
vssrvc.exe                    2352                            0      5,724 K
WmiPrvSE.exe                  2692                            0      5,028 K
wisptis.exe                   3428 Console                    1      5,020 K
TabTip.exe                    3452 Console                    1     12,244 K
dwm.exe                       3572 Console                    1     89,924 K
explorer.exe                  3580 Console                    1     39,060 K
taskeng.exe                   2780                            0      4,748 K
taskeng.exe                    500 Console                    1      8,688 K
WmiPrvSE.exe                  2524                            0      5,288 K
MSASCui.exe                   3188 Console                    1      6,156 K
Realmon.exe                   3292 Console                    1      5,752 K
00THotkey.exe                 3412 Console                    1      5,600 K
TRot.exe                      1436 Console                    1      3,744 K
wmdWatch.exe                  1168 Console                    1      3,732 K
sidebar.exe                   2532 Console                    1     28,832 K
msnmsgr.exe                   2944 Console                    1      4,464 K
svchost.exe                   1912                            0      5,128 K
communicator.exe              3948 Console                    1     55,100 K
Msmsgs.exe                    1948 Console                    1      2,224 K
ehtray.exe                    3684 Console                    1      1,724 K
ONENOTEM.EXE                  3272 Console                    1        444 K
ehmsas.exe                    1240 Console                    1      3,072 K
ehsched.exe                   4000                            0      3,908 K
InputPersonalization.exe      3060 Console                    1      8,512 K
unsecapp.exe                  2932 Console                    1      4,068 K
ehrecvr.exe                   4408                            0      4,544 K
ieuser.exe                    1480 Console                    1     17,312 K
iexplore.exe                  3248 Console                    1     42,036 K
WINWORD.EXE                   5744 Console                    1     39,392 K
TrustedInstaller.exe          5344                            0      3,364 K
cmd.exe                       6136 Console                    1      2,208 K
SearchFilterHost.exe          5224                            0      7,016 K
SearchProtocolHost.exe        5844 Console                    1     11,424 K
iexplore.exe                  6016 Console                    1     60,448 K
cmd.exe                       5108 Console                    1      2,132 K
notepad.exe                   3080 Console                    1      6,792 K
WmiPrvSE.exe                  3120                            0      6,108 K
tasklist.exe                  5516 Console                    1      4,148 K

E:\Users\stephlam>taskkill /pid 3080
SUCCESS: Sent termination signal to the process with PID 3080.

 

 

Comments
  • Problem You want a quick way to kill a process on your system, or kill and restart an ASP.NET or IIS

  • If this floats your boat, then you should be spending some time with the new Windows Power Shell (FKA Monad). If that does not satisfy your ps -ef | grep... needs then you need to just install a KSH on Vista ;o)

  • When  I made my "Vista Cool wall" post, I said there were some new command line tools. I came across...

  • Hiya,
    Taskkill is also avalable under XP ...

    Sometimes the PID is not displayed so My personal favourite is
    taskkill /f /im "process/service_name"
    taskkill /f /im explorer.exe

    The same command line can also be used to kill multiple processes
    taskkill /f /im iexplorer.exe /im calc.exe

    Does this make sense ?

    A

  • Arthur> Thanks for your suggestions. I noticed yesterday that it's available on XP and most likely 2003 too though I haven't tried that.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment