11

I will sometimes get a process such that if I run taskkill /im the_process.exe /f /t, then it won't kill it, because: ERROR: The process with PID 6492 (child process of PID 5788) could not be terminated. Reason: There is no running instance of the task.

But if I open Task Manager and click End Process, then it goes away. Why does task manager work but taskkill not? I need to be able to kill the process programically, so I need to find a CLI command that will successfully kill this process.

I've googled around but I haven't found a working solution yet.

Jeff M
  • 2,492
  • 3
  • 22
  • 38
  • `powershell kill -n the_process` ? – Zombo Dec 19 '14 at 19:02
  • Nada. `kill : Cannot find a process with the name "the_process.exe". Verify the process name and call the cmdlet again. At line:1 char:1 + kill -n the_process.exe + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (the_process.exe:String) [Stop-Process], ProcessCommandException + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.StopProcessCommand ` I also tried without the ".exe". I also tried with an asterisk at the end. I also tried running the cmd window as admin. – Jeff M Dec 19 '14 at 20:01
  • Can you divulge a little more about this process? Are you absolutely certain that this process is actually running? – Zombo Dec 19 '14 at 21:04
  • The process name appears in task manager, and taskkill can tell it exists because it finds the PID. Otherwise, taskkill would simply say `ERROR: The process "the_process.exe" not found.` On the other hand, I can rename/move/delete the exe file without Windows complaining. – Jeff M Dec 19 '14 at 21:39
  • 1
    So *after* the message is printed that there's "no running instance of the task" [with PID 6492], you still see 6492 listed in Task Manager? That would be a bug. But if it's actually no longer listed in Task Manager, then this is just a race condition where the process with PID 6492 was waiting on a child process that got terminated, and subsequently killed itself before `taskkill` could call `TerminateProcess`. – Eryk Sun Dec 19 '14 at 21:58
  • Yes, it's still in task manager. But task manager isn't the only one that thinks the process is still running. If I run the same taskkill command again, I get the same result. Process with PID could not be terminated. But if the process was truly gone, then taskkill would have said Process not found. – Jeff M Dec 19 '14 at 23:03
  • 4
    This is a bug in Windows that has been there for YEARS. If you call the right kernel functions at the right time, you will get a phantom process. It doesn't happen often, but if you manage hundreds of computers, you'll see it at least once a month. That means the average user may experience it once every couple of years. – Brain2000 Jan 29 '16 at 14:19

3 Answers3

1

Also, if are debugging the process under Visual Studio, you will get this exact situation. You need to detach the debugger or terminate the process from the debugger.

BenV136
  • 319
  • 2
  • 5
0

I just had the exact same issue, while programming a piece of software in codeblocks.

It ended up being that Codeblocks was still debugging it, and I had to press the red play button (F8) on the top menu to continue. Check to make sure no other programming is linked to your app.

Monofuse
  • 735
  • 6
  • 14
0

This is for 'Taskkill /f doesn't kill a process' as well. These are "special circumstances" but I suspect others also operate like I do - remote worker RDPd to an onsite desktop. It won't be everyone's solution but so far is mine and I think worth sharing.

I have been plagued with my Citrix client getting messed up such that I can't open a new session; can't kill wfica32.exe processes - get Access denied or There is no running instance of the task. with tasklist. Tried all the variety of suggestions none of which has worked - always ended up rebooting which of course, is a pain.

But I happened to run Tasklist with /V and the RDP was the clue - I simply disconnected the RDP session I was operating in and reconnected - all the wfica tasks were gone and I could now reopen my Citrix session.

wfica32.exe                  63636 RDP-Tcp#16
PTurner
  • 11
  • 1