You can read the article that Glenn mentioned, but that won't help.
Perhaps you need the right permissions combined with access to the 64-bit registry representation :
with _winreg.CreateKeyEx(_winreg.HKEY_LOCAL_MACHINE,
r"Software\Microsoft\Shared Tools\MSCONFIG\startupreg\test\",
0,
_winreg.KEY_WOW64_64KEY | _winreg.KEY_ALL_ACCESS) as key:
_winreg.SetValueEx(key, "testValueName", 0, _winreg.REG_SZ, "value")
Pay attention to the combination of these _winreg.KEY_WOW64_64KEY | _winreg.KEY_ALL_ACCESS.
source
share