I would like to remove values ββfrom the registry in Windows using Python, but I don't understand what sub_key is in the python documentation:
I have the following code that I would like to use:
def del_env(name): key = OpenKey(HKEY_CURRENT_USER, 'Environment', 0, KEY_ALL_ACCESS)
This function should be used as
del_env("SOMEKEY")
ps I forgot to mention if I use:
deleteKey(key,"")
All environment variables in the session are erased ...
Thanks in advance, Oz
My glorious failure:
: C:\etc\venus\current\bin>python.bat Python 2.4.4 (#0, Jun 5 2008, 09:22:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import _winreg >>> key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,r"Environment") >>> _winreg.DeleteKey(key,"OZ") Traceback (most recent call last): File "<stdin>", line 1, in ? WindowsError: [Errno 2] Das System kann die angegebene Datei nicht finden
Oz123 source share