Aug-17-2024, 07:44 AM
Windows doesn't grant administrative privileges to scripts by default.
If run cmd as Administrator the run python script it will work.
There are packages that deal with this eg pyuac
Teset work.
If run cmd as Administrator the run python script it will work.
There are packages that deal with this eg pyuac
Teset work.
import os, time import pyuac file_path = r'C:\Program Files (x86)\game\pong – Kopi.exe' if not pyuac.isUserAdmin(): pyuac.runAsAdmin() os.remove(file_path)Do not do this when use a file path,because of escape characters.
# No 'C:\Program Files (x86)\Microsoft' # Ok r'C:\Program Files (x86)\Microsoft' 'C:/Program Files (x86)/Microsoft'