_winreg.CreateKey problem in Python

I am trying to create such a key

_winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\')

and the key is created here

HKLM\Software\Wow6432Node\Microsoft\Shared Tools\MSCONFIG\startupreg\test\

why?

Yes, Windows 7 64x is here

+3
source share
2 answers

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.

+1
source

Source: https://habr.com/ru/post/1735530/


All Articles