Scott Hanselman

Taskkill and Pskill

March 20, 2006 Comment on this post [3] Posted in PowerShell
Sponsored By

A very useful utility included with Windows XP and 2003 that a lot of folks may not be familiar with is Taskkill. This is installed in %WINDIR%\SYSTEM32\taskkill.exe. Here's some examples:

 TASKKILL /S system /F /IM notepad.exe /T
 TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
 TASKKILL /F /IM notepad.exe /IM mspaint.exe
 TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
 TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *

Nice things are that you can blow stuff away by Window Title, CPU Time, Status, using filters. It's not as flexible as stop-process in MSH, but I'll talk about Monad on this week's Hanselminutes and in a later blog post.

I've got a batch file called cleanprocesses.bat that is filled with "net stop" and "taskkill" commands that takes my number of processes down from my standard 103 to 50. While extreme, I've found that when I'm giving a talk this makes my machine more stable. (Of course, not starting up the superfluous processes in the first place would be more clever.)

If you're running Windows 2000, I like PSKILL as an alternative.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 21, 2006 7:16
But not WinXP Home. Arghhh! When you try to do tech support at a relatives and find all your tools aren't available
March 21, 2006 7:17
Also, taskkill is actually a derivative of kill.exe from the Windows 2000/WinNT resource kit
March 21, 2006 8:05
Yeah, RichB, I hate that. Stupid market segmentation.

Neat trick though, I'll check it out. Win2k3 has a bunch of addons like this, I haven't had a chance to play with it too much. Considering it is a dual proc opteron system, I really should use it more...

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.