我想通过以下代码使用 python 添加一个注册表项:
import _winreg
from time import sleep
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,'Software\\Microsoft\\Windows\\CurrentVersion\\Run',_winreg.KEY_SET_VALUE)
_winreg.SetValueEx(key,'Windows-Update',0,_winreg.REG_BINARY,'C:\Windows\System32\SystemSetting\Block.exe')
key.Close()
但它显示了这个错误WindowsError: [Error 5] Access is denied
。
有什么解决办法吗?
编辑 - 我已经以管理员身份运行它
EDIT2 - 它是否与KEY_ALL_ACCESS