Skip to content

Instantly share code, notes, and snippets.

@fruch
Created March 2, 2016 19:06
Show Gist options
  • Save fruch/7a17af25630786770f58 to your computer and use it in GitHub Desktop.
Save fruch/7a17af25630786770f58 to your computer and use it in GitHub Desktop.
Find Office records in registery
import _winreg
def subkeys(key):
i = 0
while True:
try:
subkey = _winreg.EnumKey(key, i)
yield subkey
i+=1
except WindowsError as e:
break
def traverse_registry_tree(hkey, keypath, tabs=0):
try:
key = _winreg.OpenKey(hkey, keypath, 0, _winreg.KEY_ALL_ACCESS)
except WindowsError as e:
#print keypath, " Error"
return
for subkeyname in subkeys(key):
#print '\t'*tabs + subkeyname
subkeypath = "%s\\%s" % (keypath, subkeyname)
if "Microsoft\\Office" in keypath:
print subkeypath
traverse_registry_tree(hkey, subkeypath, tabs+1)
keypath = r"SOFTWARE"
traverse_registry_tree(_winreg.HKEY_LOCAL_MACHINE, keypath)
traverse_registry_tree(_winreg.HKEY_CURRENT_USER, keypath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment