Search code examples
pythonprocess

In python how to disable Task Manager?


I tried this code but it didn't worked:

import subprocess
from time import sleep

si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW

while True:
  subprocess.call("taskkill /F /IM Taskmgr.exe", startupinfo=si)
  sleep(1)

ERROR: The process "Taskmgr.exe" with PID 5220 could not be terminated.

Reason : Access denied.


Solution

  • You don't have sufficient permissions, you should be an Administrator to kill Task Manager.

    Execute python.exe as an Administrator. You can do this by right clicking the Python icon and then click "Run as administrator...".