Created
March 2, 2016 19:06
-
-
Save fruch/7a17af25630786770f58 to your computer and use it in GitHub Desktop.
Find Office records in registery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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