Tizzi
Tizzi

Reputation: 1

How delete a file in system32 folder with python?

for the thesis work on forensic analysis I should try to automatically delete a file created and placed in the "system32" folder.

This is the code I ran:

os.system("C://Windows//System32//update.exe")
os.chmod("C://Windows//System32//update.exe", stat.S_IRWXU)
os.remove("C://Windows//System32//update.exe")

The error is as follows:

Traceback (most recent call last): File "C:\Users\xxxx\PycharmProjects\Tesi\main.py", line 5, in <module> os.chmod("C://Windows//System32//update.exe", stat.S_IRWXU) PermissionError: [WinError 5] Accesso negato: 'C://Windows//System32//update.exe'

How can I run it with the right permissions?

Upvotes: 0

Views: 2572

Answers (1)

Leo
Leo

Reputation: 1303

Depends on how you are running the Python interpreter. If you are using Powershell, you can Right-click the Powershell icon and run it as Administrator. After this, any Python script you run from that shell will also run with admin rights.

Upvotes: 1

Related Questions