该程序应将另一个程序写入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)