Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinSCP: Support for 'for you only' installations & other bug fixes #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions WinSCP/winscp.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ def _detect_distro_official(self, given_enabled, given_label, given_path, given_



def _autodetect_official_installreg(self):
def _exe_from_reg(self, reg_root):
try:
key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
reg_root,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\winscp3_is1",
access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
value = winreg.QueryValueEx(key, "InstallLocation")[0]
Expand All @@ -282,6 +282,11 @@ def _autodetect_official_installreg(self):
pass
return None

def _autodetect_official_installreg(self):
hkcu = self._exe_from_reg(winreg.HKEY_CURRENT_USER)
return (hkcu if hkcu is not None
else self._exe_from_reg(winreg.HKEY_LOCAL_MACHINE))

def _autodetect_official_progfiles(self):
for hive in ('%PROGRAMFILES%', '%PROGRAMFILES(X86)%'):
exe_file = os.path.join(
Expand All @@ -291,8 +296,9 @@ def _autodetect_official_progfiles(self):

def _autodetect_startmenu(self, exe_name, name_pattern):
known_folders = (
"{625b53c3-ab48-4ec1-ba1f-a1ef4146fc19}", # FOLDERID_StartMenu
"{a4115719-d62e-491d-aa7c-e74b8be3b067}") # FOLDERID_CommonStartMenu
"{625b53c3-ab48-4ec1-ba1f-a1ef4146fc19}", # FOLDERID_StartMenu
"{a4115719-d62e-491d-aa7c-e74b8be3b067}", # FOLDERID_CommonStartMenu
"{a77f5d77-2e2b-44c3-a6a2-aba601054a51}",) # FOLDERID_Programs

found_link_files = []
for kf_guid in known_folders:
Expand All @@ -309,7 +315,7 @@ def _autodetect_startmenu(self, exe_name, name_pattern):
for link_file in found_link_files:
try:
link_props = kpu.read_link(link_file)
if (link_props['target'].lower().endswith(exe_name) and
if (link_props['target'].endswith(exe_name) and
os.path.exists(link_props['target'])):
return link_props['target']
except Exception as exc:
Expand Down