用于在Windows 64位中禁用自动运行功能的python脚本

时间:2014-01-03 17:15:16

标签: python

我试图用这个python脚本禁用autrun但是后面的错误正在......任何人???

from _winreg import *
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)

aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")                                      

print r"*** disabling auto run  ***"
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer", 0, KEY_WRITE)
try:   
   SetValueEx(aKey,"MyNewKey",0, REG_SZ, r"c:\winnt\explorer.exe") 
except EnvironmentError:                                          
    print "Encountered problems writing into the Registry..."
CloseKey(aKey)
CloseKey(aReg)            

错误是

追踪(最近一次通话): **

IDLE Internal Exception: 
  File "C:\Python27\lib\idlelib\run.py", line 324, in runcode
    exec code in self.locals
  File "C:\Users\debu\Desktop\proscript\disautorun.py", line 7, in <module>
    aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer", 0, KEY_WRITE)
WindowsError: [Error 5] Access is denied

0 个答案:

没有答案