import _winreg key = None KEY_WOW64_32KEY = 0x0200 try: key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, \ r"SOFTWARE\Microsoft\VisualStudio\9.0", 0, \ _winreg.KEY_READ | KEY_WOW64_32KEY) val, type = _winreg.QueryValueEx(key, "InstallDir") print val except EnvironmentError, ex: print ex finally: if key: _winreg.CloseKey(key)