The end of 2008 is approaching, making it an appropriate time to take inventory of my life — which also includes a lot of my computer-related stuff.  In addition to cleaning up my office, I'm also cleaning up my Lenovo Thinkpad T60p, my primary work computer, whose drive has been close to its 100 GB limit for some time now. To help me spot the disk hogs, I've been running WinDirStat – Windows Directory Statistics.
I'm also looking through all the programs I've installed over the years, lot of which I've not used and should be uninstalled to save space! Although I've been using Windows XP's Control Panel's Add/Remove Program, I would also like to have some automated way to inventory my system — hence I started looking for Python code to do so.
I found the following code in List of all installed applications (XP)?:
import win32api, win32con, pywintypes appKey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, \ 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths', 0, win32con.KEY_READ) sklist = win32api.RegEnumKeyEx(appKey) for skey in sklist: print skey[0] try: wPath = win32api.RegQueryValue(appKey, skey[0]) print ' ' + wPath except pywintypes.error,details: print '### Error [pywintypes.error]: ' + details[2] win32api.RegCloseKey(appKey)
The code seems to work. The response to query for a better technique pointed to Tim Golden's Python Stuff: wmi. WMI looks cool and worthwhile following up with, especially because of what seems to be excellent documentation in the form of wmi Tutorial and wmi Cookbook.
Post a Comment