Search code examples
pythonregistrywinreg

How to create a key in Windows registry without admin permissions?


import _winreg as wreg
key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "Software\\testfolder")

I can't seem to make this code work without admin permissions. Is there something I need to add to my code to make this work? Or is the best way to go about this, prompting for admin permissions? If so, how do I get Windows to generate that prompt?

Thanks so much.


Solution

  • key = wreg.CreateKey(wreg.HKEY_CURRENT_USER, "Software\\testfolder")
    

    I think you can do ... if you need to write to a keyspace that requires admin(eg. LOCAL_MACHINE) you will need to elevate permissions