I am using winreg.DeleteKey to delete keys from the registry. I have no problems using the API; however I'm getting a weird problem where, if I delete a key from HKEY_LOCAL_MACHINE\SOFTWARE, the code successfully runs and deletes (and if i run it again it says it cannot find the key since it was just deleted), but the key is still shown in Regedit EVEN AFTER REBOOTING!
I can even edit the values of the key within Regedit! But if I try to delete the key again, WindowsError is raised that says it can't find the file specified even though it worked the first time!
Does anybody know what's happening? This is baffling, and I can't seem to find any info on this.
EDIT: Apparently a 32-bit application opens the 32-bit key, not the 64-bit key. When I try to open the key like so:
aKey = winreg.OpenKeyEx(akey, subkey_str, 0, winreg.KEY_WOW64_64KEY)
I get an "access is denied" error message. I have tried running the script with runas, opening terminal as admin. My user account has administrator privileges, and I event went so far as to check the privilege on the key itself. Administrator and all users have full access to the key.
Any ideas why I can't open it?