Jul-25-2018, 02:12 AM
How can I get access to an administrator-level access registry key via code? I read this article linked in the official docs, but I'm not sure where to go. The straight forward method is not working. Apparently I need to take ownership of the key? Here's the code that returns an access is denied error:
import winreg, ctypes reg_key = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList' with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software', 0, winreg.KEY_ALL_ACCESS) as k: print(winreg.EnumKey(k, 0))Google hasn't been too helpful. And before someone suggests it, I know I can give permission via Windows (regedit) and running the command prompt as admin can be done as well. I haven't tried either, but I don't want to do it that way, I want to do it via code. Hopefully someone here is familiar with registry related coding.