Sebastian Southwell
Sebastian Southwell

Reputation: 160

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

Upvotes: 0

Views: 592

Answers (1)

ib14
ib14

Reputation: 36

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.

Upvotes: 2

Related Questions