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

Paul report at bugs.python.org
Thu May 6 14:16:42 EDT 2021


Paul <paulenet at gmail.com> added the comment:

"The most easy way to do is right click on the application you're running the code from, click Run as Administrator and then run the code in that application. You'll not get any WinError. And also being in the Administrators group doesn't mean whatever application you run has the permission. You have the permission to do manually not the application right? I'm saying this because I'm the admin of my computer still Python raises WinError if I run it normally. Being the admin of my computer I still have to run Python in elevated mode. Windows considers Python as a third party app and it'll not give admin access to it so easily."

@Shreyan, Yes, totally understand that.  I am also keenly aware of this, because often times for low-level, environment-related solutions in Visual Studio, I have had to set Visual Studio IDE to run as administrator in order for certain operations to function properly.  In the case of Python, I am currently using VSCode.  When I have set code.exe to run as administrator, and configure python.exe to run as administrator under Compatibility mode, then both VS Code and Python starts acting strange.  From the IDE, I can no longer run in debug mode, and any output that is generated is launched in a separate console window, which is viewable only briefly.

So... what I also tried was just eliminating VS Code from the equation at the moment.  I run a DOS console as Administrator, then just call Python directly along with the .py, and the WinError 5 stops getting thrown.  However, the other thing I noticed is that when python.exe is set to run as administrator under Compatibility Mode, and you reopen solution in VS Code, I noticed that the winregistry library stops getting recognized.

----------

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


More information about the Python-bugs-list mailing list