I created a small IronPython Script to list all Installed Software from a Windows PC.
import _winreg
def subkeys(key):
i = 0
while True:
try:
subkey = _winreg.EnumKey(key, i)
yield subkey
i+=1
except:
break
def traverse_registry_tree(key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"), tabs=0):
output = []
for k in subkeys(key):
meep = _winreg.OpenKey(key,k)
if _winreg.QueryValueEx(meep,"DisplayName")[0] == None:
string = str(k)
else:
string = str(_winreg.QueryValueEx(meep,"DisplayName")[0])
output.append('\t'*tabs + string)
traverse_registry_tree(k, tabs+1)
output.sort()
return output
output_file = open("output.txt",'w')
for line in traverse_registry_tree():
tmp = line + '\n'
output_file.write(tmp)
output_file.close()
After compling it with the following Options:
/main:wmi_test.py /out:test /embed /standalone /target:winexe
I generated the output.txt from the executable and the output.txt from the script. There is however a big difference between them: http://www.diffchecker.com/wfbh79af
Here is a screenshot from "Uninstall Software" in the Windows Configuration Center: http://jschpp.de/software.png
Could you help me to understand why there is such a big discrepancy.
I am using IronPython 2.7 on Windows 7 Professional x64
When you say script, I assume you mean using ipy.exe wmi_test.py
. The ipy.exe
shipped with ironpython is a 32-bit executable (for various reasons); the executables built with pyc.py
are AnyCPU, which means 64-bit for you. Windows has different registries for 32 and 64 bit programs.
An easy way to check that this is the case is to run the script with ipy64.exe
instead and compare the results.