程序将其他程序写入注册表运行键但程序无法启动

时间:2017-02-02 15:33:25

标签: python python-3.x registry python-3.6

该程序应将另一个程序写入Run键。它做到了,但程序不会自行启动。

from winreg import *
import os
import time
aReg = ConnectRegistry(None,HKEY_CURRENT_USER)
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 0, KEY_WRITE)
try:
   print ("Setting up registry.")
   SetValueEx(aKey,"Reminder",0, REG_SZ, ("%s\writereminder.pyw" % os.path.dirname(os.path.realpath(__file__))))

   print ("Success!")
except EnvironmentError:
    print ("It didn't work")
CloseKey(aKey)
CloseKey(aReg)
time.sleep(7)

0 个答案:

没有答案