Skip to content


Killing processes in Windows with a batch script

We’ve all had, at least a few times, some random program that would freeze and that for some reason the Windows Task Manager would fail to terminate in a timely manner. It turns out that I have, at the moment, a couple of repeating offenders in that matter. A freeze a few times a year is slightly annoying, but a couple of freezes each week seriously got on my nerves.

So I searched a little, and eventually found a way to kill a program instantly, skipping any pre-exit confirmation. Simply this:

taskkill /F /IM calc.exe

It will kill all processes from executable calc.exe, immediately. If it’s always the same program causing issue, you can just put it in a batch file (.bat) and run it whenever you need. I did that for 2 programs, one of which doesn’t even freeze, but I wanted to skip the long exit process, as an unclean exit causes no issue for this program.

If you want to keep the pre-exit confirmation, lose the /F:

taskkill /IM calc.exe

You can also kill by process ID. It’s nice when you have multiple instances of a program running, and you just want to kill a particular one (for instance just one browser tab that’s gotten out of control). But the drawback is, as process IDs always change, that you can’t make a batch file that you’ll just have to click: you’ll need to look up the process ID every time. The syntax is:

taskkill /PID [process ID]

Source, plus quite a few more examples / ideas: https://www.windows-commandline.com/taskkill-kill-process/

I tried this on Windows 10, but I assume it already works in Windows 7 / 8, and possibly even XP.

Posted in Windows.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA