How would I loop through all the values of a Windows Registry Key using the Python module _winreg. I have code that will do what I want, but it is for the subkeys of the specified registry key.
Here Is The Code:
from _winreg import *
t = OpenKey(HKEY_CURRENT_USER, r"PATH TO KEY", 0, KEY_ALL_ACCESS)
try:
i = 0
while True:
subkey = EnumValue(t, i)
print subkey
i += 1
except WindowsError:
# WindowsError: [Errno 259] No more data is available
pass
Oh, figured it out. But, if anyone knows of another way to do it, I'll still accept that answer!
-1
in xrange leaves out the last key. I think it should simply befor i in xrange(_winreg.QueryInfoKey(key)[0]):
– Ranket