Get Cygwin installation path in Python script

I am writing a cross-platform python script that needs to know where and where Cygwin is installed if the platform is NT. Right now, I'm just using a naive check for the default installation path "C: \ Cygwin". I would like to be able to determine the installation path programmatically.

The Windows registry is not an option because Cygwin no longer stores mount points in the registry. Is it even possible to programmatically get the Cygwin installation path?

+3
source share
3 answers

Only valid for Cygwin 1.7:

HKEY_CURRENT_USER HKEY_LOCAL_MAHINE Cygwin. , Cygwin , .

.

CYGWIN_KEY = "SOFTWARE\\Cygwin\\setup"
hk_user = winreg.HKEY_CURRENT_USER
key = winreg.OpenKey(hk_user, CYGWIN_KEY)
root = winreg.QueryValueEx(key, "rootdir")[0]

script HKEY_LOCAL_MACHINE. , Cygwin .

+2

HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup\rootdir Cygwin 1.7

0

Source: https://habr.com/ru/post/1726016/


All Articles