[issue44046] When writing to the Registry using winreg, it currently allows you to write ONLY to HKEY_CURRENT_USERS.

Shreyan Avigyan report at bugs.python.org
Wed May 5 14:48:50 EDT 2021


Shreyan Avigyan <shreyan.avigyan at gmail.com> added the comment:

> I can also add, modify, and delete Registry entries in HKLM (or any other hive) by hand with no problem, so it is definitely not a permissions issue.

When you run regedit you get an admin pop up, right? Like that also run python in admin mode.

> I can also write, update, modify, etc. anything in HKLM using C# just fine, but NOT with winreg in Python.  

I've never used C# but as far as I know it doesn't use win32api while Python does. C# is specifically designed to work with these while C is not therefore it uses win32api. Python uses the C interface of win32api. 

> Keep in mind that the exact same Registry write methods work as long as you are pointed to HKCU hive. However, if you point to HKLM and do not change anything else, winreg will throw a permissions error every time, no matter what combination of permission flags you specify.
> You will be able to reproduce and see the problem if you try the two examples I provided.  Have you tried the two code snippets I provided yet?  Please do so, and confirm the outcome so that you are on the same page.

Please provide an example that does not involve setting of values (I actually don't want to mess with my registry). If this is occurring while setting of values then I am on right track. If it's not then this requires quite a investigation and debugging. 


Lastly a WinError always means Access Denied. AFAICT this is a permission problem.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44046>
_______________________________________


More information about the Python-bugs-list mailing list