426

Occasionally a program on a Windows machine goes crazy and just hangs. So I'll call up the task manager and hit the "End Process" button for it. However, this doesn't always work; if I try it enough times then it'll usually die eventually, but I'd really like to be able to just kill it immediately. On Linux I could just kill -9 to guarantee that a process will die.

This also could be used for writing batch scripts and writing batch scripts is programming.

Is there some program or command that comes with Windows that will always kill a process? A free third-party app would be fine, although I'd prefer to be able to do this on machines I sit down at for the first time.

8
  • 23
    Stray processes is a common enough problem in programming that I have to disagree; this is not an off-topic question. Commented Sep 3, 2015 at 18:10
  • 25
    I deal with process management every day as a developer. This is totally ON topic for me! Commented Oct 5, 2015 at 19:25
  • 17
    I strongly advise against deleting this question. +195 and it's a really early google hit for the question involved. Commented Apr 26, 2016 at 20:38
  • 2
    "unless they directly involve tools used primarily for programming" I ran into this issue in regards to Visual Studio keeping a process running which made me unable to kill it. Closing Visual Studio helped kill the problematic process. Commented Jul 25, 2016 at 14:18
  • 1
    You can use the Stop-Process powershell cmdlet. Commented Dec 12, 2016 at 16:36

12 Answers 12

346

"End Process" on the Processes-Tab calls TerminateProcess which is the most ultimate way Windows knows to kill a process.

If it doesn't go away, it's currently locked waiting on some kernel resource (probably a buggy driver) and there is nothing (short of a reboot) you could do to make the process go away.

Have a look at this blog-entry from wayback when: http://blogs.technet.com/markrussinovich/archive/2005/08/17/unkillable-processes.aspx

Unix based systems like Linux also have that problem where processes could survive a kill -9 if they are in what's known as "Uninterruptible sleep" (shown by top and ps as state D) at which point the processes sleep so well that they can't process incoming signals (which is what kill does - sending signals).

Normally, Uninterruptible sleep should not last long, but as under Windows, broken drivers or broken userpace programs (vfork without exec) can end up sleeping in D forever.

Sign up to request clarification or add additional context in comments.

17 Comments

While I hate that this is the correct answer, there's no doubt in my mind that it is more correct than taskkill below.... stupid buggy drivers!
Slighly less annoying than a reboot is to log off/on again. Still lose work, but not quite so much time perhaps.
that's caused by some other process making sure the initial process is always running. You killed your old instance and a new one has been started by the watchdog
This answer is not correct at all. "End Process" is not the most ultimate way to kill processes, as it can't kill service processes (for example). taskkill /f is the most ultimate.
TaskKill /f only calls the TerminateProcess API. It does exactly the same thing as the Task Manager (though, you're right on that, with elevated privileges).
|
293
taskkill /im myprocess.exe /f

The "/f" is for "force". If you know the PID, then you can specify that, as in:

taskkill /pid 1234 /f

Lots of other options are possible, just type taskkill /? for all of them. The "/t" option kills a process and any child processes; that may be useful to you.

15 Comments

Just a note. This is particularly useful if you are writing scripts for server management. kill.exe (from the NT Res kit) will cause a program to exit, but if you have a crash handler installed (particularly windbg), it can cause issues as the OS will see the killed process as having crashed, and attempt to debug it. Taskkill will not result in this issue.
@lzprgmr - taskkill and "end task" probably both call the same underlying windows function "TerminateProcess" msdn.microsoft.com/en-us/library/windows/desktop/…
THis is no more effective then "end process" from task manager.
I've been trying to forcefully kill SugarSync.exe without having to reboot (since restarting SugarSync twice before it really gets going makes it work again), but taskkill /T /F /IM SugarSync.exe doesn't work--even though it claims "SUCCESS"
THANK YOU! taskkill /pid 1234 /f does work when End Task refuses to work! WOW!
|
42

Process Hacker has numerous ways of killing a process.

(Right-click the process, then go to Miscellaneous->Terminator.)

17 Comments

Can't find much in the way of corroboration, as searching for this just yields millions of FREE DOWNLOAD!!! links. But it does what it says it does, virus risks and all.
@Nuzzolilo: Sure! Right-click the process, go to Miscellaneous->Terminator.
Does not work on all processes, I had one that survived all options.
It bluescreened my computer. The process went away after the reboot. Good job... -.-'
Unfortunately Terminator is removed in v2.39 :(
|
30

JosepStyons is right. Open cmd.exe and run

taskkill /im processname.exe /f

If there is an error saying,

ERROR: The process "process.exe" with PID 1234 could not be terminated. Reason: Access is denied.

then try running cmd.exe as administrator.

5 Comments

Running as administrator, the error changes. It now says: ERROR: The process with PID 17888 (child process of PID 17880) could not be terminated. Reason: There is no instance of the task. and it is referring to the parent PID 17880. As it can't find the parent, it won't kill the orphaned child. :(
"you must kill child process too if any spawned to kill successfully your process" try this stackoverflow.com/questions/12528963/…
In my case, the zombie process I told it to kill was the only child and there was no parent, though the zombie still thought it had a parent. In my case, resolved by using the Windows 8.1 Settings Advanced Repair System path, but canceling from actually wiping any disk, and just doing a full forced reboot. The regular shutdown and reboot is really sleep/hibernation (to save time on startup). Non-trivial getting it to do a full shutdown.
"Access is denied" means that the process is already in the process of being closed. For example if you had just attempted to close it earlier. You'll need to wait till it gets closed.
taskkill results under admin rights: Access is denied.
22

Get process explorer from sysinternals (now Microsoft)

Process Explorer - Windows Sysinternals | Microsoft Docs

1 Comment

That does provide more info (and some limited ability to search for lock handles) but I've not had any more success at killing tasks with it than with basic Task Manager. Certain processes (like anti-virus, and SugarSync.exe) simply refuse to die.
16

One trick that works well is to attach a debugger and then quit the debugger.

On XP or Windows 2003 you can do this using ntsd that ships out of the box:

ntsd -pn myapp.exe

ntsd will open up a new window. Just type 'q' in the window to quit the debugger and take out the process.

I've known this to work even when task manager doesn't seem able to kill a process.

Unfortunately ntsd was removed from Vista and you have to install the (free) debbugging tools for windows to get a suitable debugger.

5 Comments

Thank you SO MUCH for this. Add "-c q" (w/o quotes) to autoquit, which makes it ideal process killer.
When Visual Studio and an application being debugged both hang, attach and kill the old instance of VS. The killer can be a new instance of VS, which can then open the old project and allow you to continue working.
I can't figure out how to download anything from that link other than winsdk_web.exe, which does nothing.
You can now get it in the Windows 10 SDK by running the installer and then unchecking everything but "Debugging Tools for Windows" (learn.microsoft.com/en-us/windows-hardware/drivers/debugger/…)
this doesn't work if the unkillable process is something you were debugging when VS crashed, since the phantom process still believes it's attached to a debugger. Even invoking VS again and trying to attach back will error. I had to restart my computer.
6

setup an AT command to run task manager or process explorer as SYSTEM.

AT 12:34 /interactive "C:/procexp.exe"

If process explorer was in your root C drive then this would open it as SYSTEM and you could kill any process without getting any access denied errors. Set this for like a minute in the future, then it will pop up for you.

1 Comment

I get the following warning when trying this, so it seems to no longer work: "Warning: Due to security enhancements, this task will run at the time expected but not interactively. Use schtasks.exe utility if interactive task is required ('schtasks /?' for details)."
3

How to Find and Kill a Process by Port in Windows

Find the Process ID (PID) for the Specified Port:

Run the following command to find the process that is listening on the desired port:

netstat -ano | find "LISTENING" | find "<PORT>"

Replace <PORT> with the actual port number you're investigating.

Kill the Process:

After finding the process ID, you can terminate it by running:

taskkill /pid <PROCESS-ID> /f

Replace <PROCESS-ID> with the PID obtained from the previous step.

Comments

1

FYI you can sometimes use SYSTEM or Trustedinstaller to kill tasks ;)

google quickkill_3_0.bat

sc config TrustedInstaller binPath= "cmd /c TASKKILL /F  /IM notepad.exe
sc start "TrustedInstaller"

Comments

1

I had this issue too, here is how I solved it.

1/ Open the « task manager « 

2/ Locate the application name in the list

3/ Once found, right click on its name then click on « properties »

4/ In the properties interface, click on « security « 

5/ Click on « edit » to change permissions

6/ « Deny » all permissions for all users, click on «  apply » then « ok »

7/ click on « advanced » for special permissions settings

8/ Remove permissions for all users

9/ click on «  apply » then « ok »

10/ click on «  apply » then « ok » again

11/ you can now kill the process on task manager as well as uninstall the app of you want to.

Comments

1

wmic process where processid="11008" call terminate

Comments

0

When ntsd access is denied, try:

ZeroWave was designed to be a simple tool that will provide a multilevel termination of any kind of process.

ZeroWave is also a easy-to-use program due to its simple installation and its very friendly graphical interface.

ZeroWave has three termination modes and with the "INSANE" mode can terminate any kind of process that can run on Windows.

It seems that ZeroWave can't kill avp.exe

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.