Registry Key Changes With Python Winreg Not Taking Effect, But Not Throwing Errors
Still really new to Python and I'm trying to write a script that will allow me to change specific registry keys on a remote machine and I'm having some trouble with it. Basically t
Solution 1:
Okay so basically there are two things you need to do: First one is, when you open a key and give access to your program, you need to be more specific, meaning that you need to specify if your machine is 32-bit or 64-bit. So, for example, my machine is 64-bit so I need to change my key opening to this:
wholeKey = winreg.OpenKey(registry, 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon', 0, winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY)
For a 32-bit machine you would need to add winreg.KEY_WOW64_32KEY
The second thing is, SetValue
does not always work, so you need to use SetValueEx
which takes 5 arguments (the added argument must be 0). So in your case:
winreg.SetValueEx(wholeKey, 'AutoAdminLogon', 0, winreg.REG_SZ, "1")
You can read more about this in the documentation.
Post a Comment for "Registry Key Changes With Python Winreg Not Taking Effect, But Not Throwing Errors"