From abd9c1dc486c428e153e75c781c0c2e25d21cfa4 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 21 Jul 2015 15:59:29 -0600 Subject: [PATCH] Use the registry to find vmrun if the default VMware install path does not exist. --- gns3server/modules/vmware/__init__.py | 28 +++++++++++++++++++++------ gns3server/utils/interfaces.py | 2 -- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gns3server/modules/vmware/__init__.py b/gns3server/modules/vmware/__init__.py index b999a946..c08d744d 100644 --- a/gns3server/modules/vmware/__init__.py +++ b/gns3server/modules/vmware/__init__.py @@ -77,12 +77,28 @@ class VMware(BaseManager): if sys.platform.startswith("win"): vmrun_path = shutil.which("vmrun") if vmrun_path is None: - vmrun_ws = os.path.expandvars(r"%PROGRAMFILES(X86)%\VMware\VMware Workstation\vmrun.exe") - vmrun_vix = os.path.expandvars(r"%PROGRAMFILES(X86)%\VMware\VMware VIX\vmrun.exe") - if os.path.exists(vmrun_ws): - vmrun_path = vmrun_ws - elif os.path.exists(vmrun_vix): - vmrun_path = vmrun_vix + import winreg + try: + vmrun_ws = os.path.expandvars(r"%PROGRAMFILES(X86)%\VMware\VMware Workstation\vmrun.exe") + if not os.path.exists(vmrun_ws): + # default path not used, let's look in the registry + hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation") + ws_install_path, _ = winreg.QueryValueEx(hkey, "InstallPath") + vmrun_ws = os.path.join(ws_install_path, "vmrun.exe") + winreg.CloseKey(hkey) + if os.path.exists(vmrun_ws): + vmrun_path = vmrun_ws + except OSError: + pass + else: + vmrun_vix = os.path.expandvars(r"%PROGRAMFILES(X86)%\VMware\VMware VIX\vmrun.exe") + if not os.path.exists(vmrun_vix): + # default path not used, let's look in the registry + hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\VMware, Inc.\VMware VIX") + ws_install_path, _ = winreg.QueryValueEx(hkey, "InstallPath") + vmrun_vix = os.path.join(ws_install_path, "vmrun.exe") + if os.path.exists(vmrun_vix): + vmrun_path = vmrun_vix elif sys.platform.startswith("darwin"): vmrun_path = "/Applications/VMware Fusion.app/Contents/Library/vmrun" else: diff --git a/gns3server/utils/interfaces.py b/gns3server/utils/interfaces.py index f0145341..6cb70097 100644 --- a/gns3server/utils/interfaces.py +++ b/gns3server/utils/interfaces.py @@ -29,9 +29,7 @@ def _get_windows_interfaces_from_registry(): import winreg - #HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces - interfaces = [] try: hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards")