Python winerror 5 access is denied using winreg - how to run Python file as admin?

42 views Asked by At
import winreg

path = winreg.HKEY_LOCAL_MACHINE

software = winreg.OpenKeyEx(path, r'HARDWARE\DESCRIPTION\System\CentralProcessor\0\\')

winreg.SetValueEx(software, 'ProcessorNameString', 0, winreg.REG_SZ, 'Intel(R)')

if software:

    winreg.CloseKey(software)

It gives me a WinError 5 when I run this code.

How can I get administrator access to this file using a Python module or script, as it needs to run with elevation?

0

There are 0 answers