tags:

views:

1476

answers:

9

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.

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.

+9  A: 
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.

JosephStyons
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.
Aaron
+8  A: 

Get process explorer from sysinternals (now Microsoft)

http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

IainMH
+2  A: 

under the command prompt check out "taskkill.exe"

For example, if you want to kill all excel.exe processes, you can run:

taskkill /im excel.exe
enigmatic
+2  A: 

On Windows XP, the taskkill command is available to do this.

taskkill /IM notepad.exe
taskkill /IM notepad*

see taskkill /? for more details.

Nathan Fritz
+9  A: 

"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 (well... not really, but they can stick around, quite dead though) a kill -9.

pilif
+1  A: 

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.

Rob Walker
A: 

Another vote for Process Explorer or pskill from SysInternals, which Microsoft eventually bought up:

http://technet.microsoft.com/en-us/sysinternals/

I rarely touch Windows, but when I need to, the SysInternals suite is one of the first tools I turn to.

David Precious
A: 

Kill.exe from the resource kit. I don't remember which version of Windows this comes in in the kit,

Abdu
A: 

For windows u can use taskkill /f /fhj.exe /t in most cases this won,t work i use taskkill /f /fi "status eq running" then i restart the explorer by just explorer.exe BUT IBPROCMAN is a task manager appliation available free and much better than WIn task MGr