简体   繁体   中英

Finding installation directory of a program on windows from python

A python program needs to find the installation location of openoffice.org, which is installed on a Windows XP computer. What is the best way to do this?

You can use the _winreg module on windows: First find out the path in the registry (eg starting regedit.exe and using its find function). Then you can query this path as I did it once to find the home directory of R:

key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\R-core\\R")
value =  _winreg.QueryValueEx(key, "InstallPath")[0]

ADDED :

If you are not familiar with the windows regstry: have a look at http://en.wikipedia.org/wiki/Windows_Registry

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM