Search code examples
pythonmoduleoperating-systemtaskkill

Taskkill Taskmgr.exe Python


I was wondering if there was a way to kill the Taskmgr.exe process with python.

I am currently working on a revision program designed to close all applications that I could use to close said program or distract me from revision in the first place. Each time coming up with a unique message to guide me back to revision.

Atm everything works apart from killing the Task Manager Process to which it continues in an infinite loop as it detects that the process is open and keeps failing to kill it.

The loop ends when the process is killed.

I am currently using taskkill but it is failing due to the error "Access is Denied"

os.system("taskkill /F /IM " + Check)

I just wanted to if there is anyway I can accomplish this in python. Thank You


Solution

  • I have found a way to close taskmgr.exe (task manger) and without admin perms.

    import os
    os.system('wmic process where name="taskmgr.exe" call terminate')
    

    It works for me every time.