I am trying to create a new value under the Run key in Windows 7. I am using Python 3.5 and I am having trouble writing to the key. My current code is creating a new key under the key I am trying to modify the values of.
from winreg import *
aKey = OpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", 0, KEY_ALL_ACCESS)
SetValue(aKey, 'NameOfNewValue', REG_SZ, '%windir%\system32\calc.exe')
When I run this, it makes a key under the Run and names it "NameOfNewKey" and then sets the default value to the calc.exe path. However, I want to add a new value to the Run key so that when I startup, calc.exe will run.
EDIT: I found the answer. It should be the SetValueEx function instead of SetValue.