Taskkill /f doesn't kill a process
Asked Answered
S

31

177

When I start up an Experimental instance of VS from VS for debugging and stop debugging (sometimes directly from the parent VS), a zombile devenv.exe process remains running which I am unable to kill. It holds on to many of my dlls.

As I am logged onto this 64bit Win7 machine as Administrator, I would expect to be able to kill any process I wish to.

I tried (from Administrator command prompt):

End Task from Task Manager.
TASKKILL /F /IM devenv.exe
PSKILL devenv.exe

None return any error and TASKKILL and PSKILL returned success messages of terminating/killing the process. But devenv.exe still runs, it is not re-spawned as the PID remains constant. It goes away only on restart of the system which is not a great solution.

Note. LockHunter shows devenv has got a lock on itself. And it cannot unlock it.

Process Monitor shows devenv to be in some kind of 'Process Profiling' loop

The above screenshot is the output of Process Monitor showing devenv to be in some kind of 'Process Profiling' loop (Right click on it and click open image in new tab to see it properly).

Any ideas how to kill such a process on Windows?

Saturn answered 21/9, 2012 at 10:41 Comment(3)
No idea why you don't get an error, but to verify one thing: Did you call these commands from an elevated command prompt? Otherwise the commands will not run with Administrator privileges, even though your account has them. (This shouldn't allow them to return success when they clearly failed though ;))Seamy
yes all commands were run from Administrator command prompts.Saturn
This sort of question is more appropriate on superuser.com. Yup, they have quite good explanations there. This one helped me.Maddeu
M
102

you must kill child process too if any spawned to kill successfully your process

taskkill /IM "process_name" /T /F

/T = kills child process

/F = forceful termination of your process
Mounting answered 15/10, 2013 at 12:51 Comment(8)
It prints two success messages in my case, but the process is still there. What the hell?Excommunication
if that would be so easy :) no, it doesn't help. I think his problem is because the unkillable process is in some loop (socket, i/o, pipes...) where the main process is system process and killing it will make system unstable. It that case I would recomend first to understand what loop is the process in. Then, if that loop is network exchange with other endpoint, then just unplug network cable or disconnect the already established connection.Tayib
I get a There is no running instance of the task That process really does not want to die!Cumulation
still help me today, though I have to kill the "child of the child" too: taskkill /f /T /PID 4172 ==> ERROR: The process with PID 4172 (child process of PID 4724) could not be terminated. ==> taskkill /f /T /PID 4724 ==> DoneCompo
Yay for the under-mentioned /T switch!Mikesell
in case of „There is no running instance of the task“ it must be killed some associated process which holds lock on this process, for example devenv.exe is associated with some_debugged_process.exePostilion
YAY! this has been affecting the enjoyment of my LIFE. thank youOdds
Did not work for me, trying to delete the Windows Defender process that uses near 100% of disk access..Inactive
P
65

The taskkill and powershell (kill) methods didn't work for me; it still said "Access Denied".

I had better luck with this:

wmic process where "name='myprocessname.exe'" delete
Parenthesis answered 4/8, 2016 at 3:4 Comment(14)
ERROR: Description = Invalid queryProsy
Windows-10. Also: ERROR: Description = Access denied (Using Admin console btw)Mal
Thank you! That worked like a charm for my stuck npmSitarski
On Win10 still failed: Deleting instance \\DESKTOP-HJC3KKE\ROOT\CIMV2:Win32_Process.Handle="41236" ERROR: Description = Access deniedJory
Amazing, thanks so much. Spent an hour on kill before I found thisRhizoid
Powershell equivalent Get-WmiObject -Query "select * from win32_process where name = 'node.exe'" | Remove-WmiObjectByline
This one still doesn't work in my case. Have a Visual Studio stuck in processes, ran the command and it says Deleting instance \\MyMachine\ROOT\CIMV2:Win32_Process.Handle="6420", Instance deletion successful. But after 5 mins I still see the VS devenv.exe process in task manager list. I guess nothing but a reboot is the only solution for me.Fall
When I run wmic command from gitbash, I have to include the query in quotes. Your command should then become: wmic process where "name='myprocessname.exe'" deleteGermann
Thanks @Malganis, I updated the answer with that change.Parenthesis
Did not work for me, trying to delete the Windows Defender process that uses near 100% of disk access..Inactive
What nonsese windows is, it's own commands cannot end it own task, its irritating. Now I understand why real enterprise apps use UNIXAulic
The "Invalid Query" error happens if you don't quote it properlyDissentient
Visual Studio was protecting the process, in my case.Alon
Wanted to add my two cents and say this is the command that ACTUALLY worked for me when the other one failed miserably. Thanks.Shuttlecock
H
42

Reboot is the only solution that worked for me (so far).

The ever excellent Mark Russonovich has a good explanation for unkillable processes.

To summarise, it's quite possible it is due to unprocessed I/O requests that hasn't been handled properly (by a device driver your program has possibly accessed)

https://techcommunity.microsoft.com/t5/windows-blog-archive/unkillable-processes/ba-p/723389

Helgoland answered 22/3, 2015 at 18:34 Comment(2)
What I did is shut it down, then restart it.Feuar
For me computer doesn't restart, freezes on Restarting ... screen, mouse is moving. I can wait 2 hours and then I must manually switch it off by button.Axenic
C
38

Just had the same issue on Windows Server 2008 R2 and nothing helped, not taskmanager or taskkill. But, windows powershell run as administrator worked with "kill -id pid"

Cessation answered 2/10, 2014 at 13:31 Comment(5)
This worked for me... though there seemed to be about a 30 second delay before the process actually went away, so at first it seemed to fail. In the case that I had it was a process that was created procedurally by another application while the system was low on resources. Process Explorer, kill process tree, and several other things failed to work, but this did the trick.Ward
Didn't work for me, gave me an error unable to kill process etc etcLatchkey
@Latchkey . I know its old, but just in case someone else sees this do what I did. Open powershell as Administrator and then run it. At first I ran it not as admin and it told me I couldn't do it. So then I ran it as admin and it worked.Droopy
This worked for me on Windows 10 with a misbehaving Windows service. Had already tried CMD, in this case PowerShell is the right toolTrichosis
No luck for me even after waiting for more than 2-3 mins. none of the command is working for me currentlyAsel
D
9

I know it's late but taskkill /im devenv.exe /t /f should work. the /t kills child processes too.

Danielledaniels answered 13/10, 2013 at 1:51 Comment(5)
This doesn't seem to work for me. It says it's successful, but the process still shows up.Unhurried
I'm facing a similar issue too but with microsoft ftp service, says terminated but continues to run cant figure it outLatchkey
If instead of /IM devenv.exe I use /PID 17888 then the error basically said that 17888 is a child of 17880 and 17880 isn't running and so can't be killed.Vinasse
this works but make sure you are using cmd from admin mode.Shrine
Did not work for me, trying to delete the Windows Defender process that uses near 100% of disk access..Inactive
G
9

In my case, after several days of fighting with this problem (it was happening to VirtualBox and µTorrent processes), I discovered it was caused by a network driver issue, provoked by Windows Update patch KB4338818 (Windows 7 x64). After uninstalling that patch everything went back to normal. I just thought it could be useful for others.

Greenway answered 31/7, 2018 at 17:35 Comment(2)
How did you discover that the update caused it? I think I would have never discovered that. ^^'Mancini
I realized the only thing that changed in my machine before the issue become apparent was the updates, so I checked which was my last update and read the release notes. It seemed suspicious and I rolled back to see if the issue was solved, which it was. Then I read on some Apache forums, don't remember which, that this update has caused trouble for them too. BTW: Last Windows Update as of 2018/Aug/10 fixes the problem with KB4338818, so it can be installed again.Greenway
T
7

I could solve my issue rearding this problem by killing explorer.exe which in turn was addicted to the process I wanted to kill. I guess this may also happen if processes open interfaces via hook which may be locked.

Trinitrotoluene answered 20/9, 2013 at 16:49 Comment(2)
I tried killing and restarting explorer.exe and that didn't work.Unhurried
When I did taskkill /IM "process_name" /T /F part of the response was: (child process of PID xxxx) so I checked that PID and it was explorer.exe, restarting it solved my issue.Bookstore
R
6

Native tskill <pid> (or tskill.exe <pid> ) worked for me on Windows 10 where no other native answer did.

In my case, I had some chrome.exe processes for which task manager's 'End Task' was working, but neither taskkill /F /T /PID <pid> nor powershell's kill -id <pid> worked (even with both shells run as admin).

This is very strange as taskkill is purported to be a better-api-and-does-more version of tskill.

In my case to kill all instances of a certain task I used FOR /F "usebackq tokens=2 skip=2" %i IN (`TASKLIST /FI "IMAGENAME eq name_of_task.exe"`) DO tskill %i

Regelation answered 17/7, 2017 at 19:9 Comment(6)
This worked for me, when none of the others did. Thx :DArchuleta
Didn't work for me. Got End Process failed for 10576:Access is denied.Parenthesis
Happening the same for me. What I cannot understand, is why? taskkill is supposed to be the same as tskill [rather better, in documentation etc.]. If someone could answer?Wampler
Seems there is no tskill in Windows 10Mchenry
Did not work for me, trying to delete the Windows Defender process that uses near 100% of disk access..Inactive
Worked for me in Windows 10 Pro, calling from Java. taskkill did not work, so this was the solution I found.Vachon
S
5

I've seen this a few times and my only solution was a re-boot.

You could try using PowerShell: Get-Process devenv | kill

But if the other methods failed, this probably will too. :-(

Slippy answered 21/9, 2012 at 11:24 Comment(2)
Sadly yes! For me also it's the case. did you ever get any solution?Reeves
Not worked for me on win10: PS D:\work\Projects\libtiff.net_bin-2.4.560.0> Get-Process NSPRip | kill PS D:\work\Projects\libtiff.net_bin-2.4.560.0> echo $? True PS D:\work\Projects\libtiff.net_bin-2.4.560.0> Get-Process NSPRip Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 0 0 56 20 0.00 41236 1 NSPRipJory
M
4

I am going to suggest something here because I recently faced the same issue and I tried every possible thing in the answers but nothing worked. I was getting errors like

ERROR: The process with PID 23908 could not be terminated. Reason: There is no running instance of the task.

using command prompt. Power shell wasn't helpful either. it would simply execute the commands and no response with process still running.

Until I decided to delete the associated '.exe' file. Since the file was active, windows would not allow the deletion, but in that warning window it gave me the name of the process which was holding up the task I wanted to kill. I was able to kill the original task and thus the buggy process.

It is definitely worth a try if none of the solutions works out.

Mulderig answered 27/12, 2017 at 21:23 Comment(1)
was really hoping.... deleting the command didn't work... access denied (even tho admin)Knockknee
P
3

If taskkill /F /T /PID <pid> does not work. Try opening your terminal elevated using Run as Administrator.

Search cmd in your windows menu, and right click Run as Administrator, then run the command again. This worked for me.

Pastille answered 19/2, 2018 at 4:2 Comment(0)
H
3

I was getting the following results with taskkill

>taskkill /im "MyApp.exe" /t /f
ERROR: The process with PID 32040 (child process of PID 54176) could not be terminated.
Reason: There is no running instance of the task.

>taskkill /pid 54176  /t /f
ERROR: The process "54176" not found.

What worked for me was sysinternal's pskill

>pskill.exe -t 32040

PsKill v1.15 - Terminates processes on local or remote systems
Copyright (C) 1999-2012  Mark Russinovich
Sysinternals - www.sysinternals.com

Process 32040 killed.

You can get pskill from the sysinternal's live site

Holmgren answered 14/3, 2018 at 22:50 Comment(3)
Didn't work for me. Got: Unable to kill process 10576: Access is denied.Parenthesis
You may need to do it from a command shell with admin rights?Mikael
pskill64 at command shell with admin rights didn't work for me either. same error "access is denied."Illiterate
H
3

taskkill /f /im "process.exe"

running cmd or .bat file as administrator worked for me

Hootenanny answered 2/9, 2021 at 1:45 Comment(0)
S
2

Some of the Exe files Dependents on Some services,

So you need find the respective service and stop first.

Spotted answered 21/9, 2012 at 11:51 Comment(1)
any hints on how to work this out? On taskmanager it doesn't show any service corresponding to devenv.exe Right now I am trying to recreate the problem, once done I will use process explorer to dig into services which could be holding it.Saturn
J
2

Running as an admin works for me:

1.search cmd in windows

2.right click on cmd select as "Run as administrator"

3.netstat -ano | findstr :8080

4.taskkill/pid (your number) /F

My result

Jillian answered 26/8, 2018 at 21:9 Comment(1)
If you get an error such as: 'nestat' is not recognized as an internal or external command, operable program or batch file. you may need to run the command as C:\Windows\system32\netstat.exe instead of just nestatHeartworm
P
2

The same problem happened to me in VirtualBox with respect to Java processes.

In my case, it was due to a bug in Windows Update patch KB4338818 (Windows 7 x64).

I solved it by doing the following:

  • Uninstall Windows Update patch KB4338818
  • Install Windows Update patch KB4338821
Polyphony answered 28/8, 2018 at 22:30 Comment(0)
S
2

For me, the way it worked is I have to kill the parent process. Figure the parent process out and kill it

taskkill /IM "parent_process_name.exe" /T /F
Selfabuse answered 4/5, 2019 at 14:25 Comment(0)
P
2

In my case none of the solutions here worked. I eventually found that the program in question was frozen trying to poll USB audio interfaces. So I unplugged a USB DAC I had connected, and to my surprise the application quit instantly. Francis' answer mentions that it could be a result of "unprocessed I/O requests that hasn't been handled properly (by a device driver your program has possibly accessed)", which might explain why this fixed it.

I suppose it really depends on what the program was doing when it froze, but if none of the other solutions are working, try disconnecting all USB devices to see if one of them could be the cause.

Prophylactic answered 11/2, 2020 at 19:3 Comment(0)
P
2

while taskkill didn't work

taskkill /f /t /pid 14492

ERROR: The process with PID 14492 (child process of PID 7992) could not be terminated.
Reason: There is no running instance of the task.

the simpler tskill has worked fine for me

tskill 14492
Plus answered 18/10, 2022 at 7:44 Comment(1)
tskill was the only thing that worked for me. Thanks for this answerEberly
S
1

I have the Problem with debugged processes with gdb in Code::Blocks. As soon it is hanging while accidentally stepping into instructions out of scope of your sources (as libs without sources or system functions) you cannot quit the debugging neither from Code::Blocks nor from Task-Manager.

I think it is an error in the implementation of gdb in Code::Blocks, but could also be in gdb ;)

My Solution:

taskkill /F /IM process.exe /T

This shows the PID of the parent process. Now kill the parent:

taskkill /PID yyyy

Both are gone.

Done.

Sackman answered 7/9, 2016 at 23:34 Comment(3)
It's possible for the parent PID to not exist.Prosy
Please specify what gdb and Code::Blocks are ;)Unbosom
Warning: if the parent process is services.exe then killing parent may cause BSODFagaceous
B
1

NirSoft's NirCmd did the job for me:

nircmd killprocess "process name.exe"

killprocess man page is here.

Bark answered 23/2, 2017 at 11:54 Comment(0)
S
1

I had the exact same issue, found this fix on another site: powershell.exe "Get-Process processname| Stop-Process" it worked for me and I was in the same boat where I had to restart, the /T would not work.

Spinelli answered 17/2, 2018 at 22:4 Comment(0)
M
1

If you download the free sysinternals suite, it has a pskill.exe application which works well for these types of tasks: pskill.exe "process_name" It works on these processes even without using its -t option.

Mikael answered 5/4, 2018 at 18:57 Comment(0)
S
1

I did the following, on an elevated powershell:

PS C:\Windows\system32> wmic.exe /interactive:off process where "name like `'java%'`" call terminate

command Output:

Executing (\\SRV\ROOT\CIMV2:Win32_Process.Handle="3064")->terminate()
Method execution successful.

Out Parameters:

instance of __PARAMETERS
{ReturnValue = 0; };

I got some syntax information on : https://community.spiceworks.com/topic/871561-wmic-error-like-invalid-alias-verb

Shaw answered 18/5, 2018 at 12:22 Comment(1)
This actually worked, should be accepted answer. ThanksSoubise
O
1

As Francis mentioned some process can not be terminated because of

"unprocessed I/O requests"

In my experience i was dealing with buggy graphic driver that would cause my game to crash and not be able to close it, as last resort i disabled the graphic driver and the process finally went away.

If your application is waiting for a resource from driver like wifi or graphic try disabling them in device manager, you need to dig a little deep to see where they hanged.

This is of course not recommended but sometimes you have nothing to lose anymore.

Oleaginous answered 21/11, 2018 at 18:50 Comment(0)
T
1

I had the same problem and as many others here have said none of the normal Kill commands worked. My problem file was an executable that was being run from a network share by a user on a Remote Desktop Server. With multiple shared users not an easy thing to restart in during a work day. Even when the user logged off the exe was still listed in Task Manager. I sent to the server where the folder was shared and from Computer Management -> Sessions found the user with the session still open from that RDP server even though he was logged off. Right Click -> Close Session and the file lock was released.

Beats me why I couldn't end the taks. The error message I was originally getting when I try and delete the file was "The action can't be completed because the file is open in System"

Hope this helps someone else.

Tamtama answered 1/3, 2019 at 2:25 Comment(0)
A
0

I faced the same issue where I started a node app in port 3000 and it didn't close correctly and the process kept running even after restart.

None of the taskkill or powershell commands running in Administrator mode worked for me.

I used MS Process Expoler > Properties > Image > Current directory (which was supposed to be the my project directory).

Finally, I had to reboot in SafeMode and rename the project folder and restart. The Node processes which were consuming port 3000 killed itself.

Abandon answered 8/9, 2017 at 16:16 Comment(0)
F
0

For killing PID Tasks running in windows:

TASKKILL  /PID "Taskname"  /F
Farewell answered 26/1, 2022 at 8:6 Comment(0)
P
0

using wmic: show all running process where name of process is cmd.exe

wmic process where name="cmd.exe" GET ProcessId, CommandLine,CreationClassName

then terminate the specific instance of process by processId (PID)

WMIC PROCESS WHERE "ProcessID=13800" CALL TERMINATE

Palmer answered 25/9, 2022 at 7:25 Comment(0)
V
-6

Run CMD as Admin will fix the problem

Veach answered 20/5, 2019 at 11:2 Comment(1)
Please give more details about what to do next after running CMD as Admin.Pickaxe
B
-9
  1. open task manager
  2. select services tab
  3. select the process( devenv.exe ) you want to kill and click services button
  4. right on the process, select properties and disable it...
Beebeebe answered 17/11, 2013 at 13:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.