I want to save the registry key "Run" using _winreg in Python. This is my code:
import _winreg
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Microsoft\Windows\CurrentVersion\Run')
_winreg.SaveKey(key, "C:\key.reg")
When executing, I get a Windows error message: "A required privilege is not held by the client"
Can anyone see what is wrong?
Modify your code as below. It works fine if it is
Run as Administrator
. I have tested it on Win7 64 bitNote: if
win32api
&win32security
are missing, install them from hereReference: Here