---
title: "Revisited: Killing a process, Introducing: TaskKiller"
url: "https://osherove.com/blog/2004/8/26/revisited-killing-a-process-introducing-taskkiller.md"
canonical: "https://osherove.com/blog/2004/8/26/revisited-killing-a-process-introducing-taskkiller.html"
published: "2004-08-26T19:54:00"
updated: "2004-08-26T19:54:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "A few days ago I blogged about a trick how to kill a process that wouldn't die . Well, the trick I had up my sleeve was good, but there were better ways, described oh so eloquently by Pavel Lebedinsky as comments to…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Revisited: Killing a process, Introducing: TaskKiller

By Roy Osherove August 26, 2004 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published August 26, 2004; technical details may be outdated.

A few days ago I blogged about a trick [how to kill a process that wouldn't die](http://weblogs.asp.net/rosherove/archive/2004/08/21/218212.aspx). Well, the trick I had up my sleeve was good, but there were better ways, described oh so eloquently by Pavel Lebedinsky as comments to that post. here are the highlights (I was referring to NTSD.exe read about it in the original post):

**Introducing TaskKill.exe**

"This was a good way to kill processes on Win2K, which doesn't come with a command line tool like kill.exe. The reason it works in some cases when task manager doesn't is because ntsd enables SeDebugPrivilege, allowing you to open processes that you otherwise wouldn't have access to.
On XP and Win2003 however you should just use **taskkill.exe**. It's _more_ reliable and should even work in some cases when **ntsd** wouldn't - for example, if the process is deadlocked on the loader lock. Ntsd will not be able to attach to such process (it will eventually time out and suspend it, but when you type 'q' it will simply quit and resume the process (unless you do .kill first)). "

**Changing a priority for system processes**

"One situation where ntsd does come in handy even on XP+ is when you want to change priority of a system process. Let's say a service (for example, msdtc) is taking up 100% CPU. You want to let it finish whatever it's doing but you don't want it to slow down your interactive processes.
So you open up task manager, right-click on the msdtc process and try to change its priority. This fails with access denied because msdtc runs as NETWORK SERVICE and its security descriptor doesn't give you any access.

Fortunately, you can launch task manager under debugger ("**ntsd** taskmgr"). Ntsd enables _SeDebugPrivilege_ in its token, and taskmgr inherits this setting so it can now open system processes too. You can even detach the debugger (type 'qd', Enter) and use this instance of task manager to kill system processes or change their priorities. "

"...Actually, it looks like on XP SP2 task manager automatically enables SeDebugPrivilege when you try to kill a process. This can easily be seen in debugger (just put a breakpoint on ADVAPI32!AdjustTokenPrivileges).
For some reason taskmgr doesn't do this when you try change priority of a process.
So starting taskmgr under debugger is only necessary if you want to change priority of a process that you normally don't have access to. It is not needed if you want to to kill such process (at least, not on XP SP2). "

Awesome. Thanks Pavel.

Anyway - thanks to his great advice and comments I've gone ahead and created a little GUI app that shows you a list of running processes and allows you to "ultra-kill" each one, even if its a system process or a service, underneath using the ntsd and taskkill.exe commands.

**Task Killer:**

Allows killing a process, filtering and it can hide in the tray. I'm using some of the DevExpress controls in there for the grid and stuff so it looks pretty nice. [Feel free to download this](http://dev.magen.com/agile/code/taskkiller.zip), it requires .Net 1.1 (1.4 MB).

yes, I know about psKill and psList. this is just a more friendly way of doing the same basic things.

Also - a note regarding [John Lam's post on psKill and psList](http://www.iunknown.com/000344.html): the two tools that already come with windows cover most of what you want them for already: TaskKill.exe and TaskList.exe (on win XP and up). TaskKill.exe already has some pretty wild command line params such as wild card filters, and you can even use equation operators to look for specific processes. who says you don't always get what you need?

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Sep 1, 2004

    ### [Sunday at the VB.Net users group: Software Architecture: Techniques, Methods, and Issues](https://osherove.com/blog/2004/9/1/sunday-at-the-vbnet-users-group-software-architecture-techni.html)

- Aug 30, 2004

    ### [Simple data binding simplified using \[BindToField\] and \[BindToValueList\]](https://osherove.com/blog/2004/8/30/simple-data-binding-simplified-using-bindtofield-and-bindtov.html)

- Aug 23, 2004

    ### [Tomorrow is DBA day, and .Net rocks is back on my mind](https://osherove.com/blog/2004/8/23/tomorrow-is-dba-day-and-net-rocks-is-back-on-my-mind.html)

- Aug 23, 2004

    ### [A Virtual PC keyboard bug and fix, a new blog, and an agile question](https://osherove.com/blog/2004/8/23/a-virtual-pc-keyboard-bug-and-fix-a-new-blog-and-an-agile-qu.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
