以下代码为何老是出现: PermissionError: [WinError 5] 拒绝访问 异常?
import winreg as reg
def proReg():
subkey = '*\shell'
key = reg.OpenKey(reg.HKEY_CLASSES_ROOT,subkey)
with key:
reg.SetValue(key,'runas',reg.REG_SZ,'TEST') # 这里抛出异常
with reg.OpenKey(key,'runas',0,reg.KEY_WRITE) as nkey:
reg.SetValueEx(nkey,'NoWorkingDirectory',0,reg.REG_SZ,'')
if name == 'main':
proReg()
1
progmboy 2017-02-15 13:43:28 +08:00 via iPhone 2
这个键是高权限的呀,已管理员运行就行了
|