当前位置 : 首页 » 互动问答 » 正文

Taskkill /f doesn't kill a process

分类 : 互动问答 | 发布时间 : 2012-09-21 18:41:11 | 评论 : 24 | 浏览 : 270968 | 喜欢 : 103

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?

回答(24)

  • 1楼
  • 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
    
  • 2楼
  • 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"

  • 4楼
  • 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
    
  • 5楼
  • I know it's late but taskkill /im devenv.exe /t /f should work. the /t kills child processes too.

  • 6楼
  • 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. :-(

  • 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.

  • 8楼
  • 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.

  • 9楼
  • Some of the Exe files Dependents on Some services,

    So you need find the respective service and stop first.

  • 10楼
  • 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.

  • 11楼
  • 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.

  • 12楼
  • 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

  • 13楼
  • if taskkill /F /T /PID <pid> does not work. Try open ur terminal by Run as Administrator.

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

  • 14楼
  • 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

  • 15楼
  • 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.

  • 16楼
  • 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

  • 17楼
  • Running as an admin works for me:

    1.search cmd in windows

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

    3.nestat -ano | findstr :8080

    4.taskkill/pid (your number) /F

    My result

  • 18楼
  • 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
  • 19楼
  • NirSoft's NirCmd did the job for me:

    nircmd killprocess "process name.exe"
    

    killprocess man page is here.

  • 20楼
  • 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.

  • 21楼
  • I had the same issue, try to run cmd as "Run as administrator".

  • 22楼
  • 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.

  • 23楼
  • Nothing from this page helped, Anvir Task Manager did.

    But it may be that my process unfroze before the kill, so please upvote/downvote if it helps you or not.

  • 24楼
    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...

相关阅读:

What are good grep tools for Windows?

Get Date in YYYYMMDD format in windows batch file

How to measure actual memory usage of an application or process?

How to set java_home on Windows 7?

How to sleep for 5 seconds in Windows's Command Prompt? (or DOS)

Failed to load the JNI shared Library (JDK)

Text editor to open big (giant, huge, large) text files

Can't start Eclipse - Java was started but returned exit code=13

How can I develop for iPhone using a Windows development machine?

Best C++ IDE or Editor for Windows