From a9eae691f6892ef2b552263d551aa564d88f9a0c Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Sun, 17 Jan 2016 23:23:53 +0200 Subject: [PATCH] Fixed the VMware default VM location on Windows, so that it doesn't assume the "Documents" folder is within the %USERPROFILE% folder, and also support Windows Server's folder (which is "My Virtual Machines" instead of "Virtual Machines"). --- gns3server/modules/vmware/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gns3server/modules/vmware/__init__.py b/gns3server/modules/vmware/__init__.py index 72f1761e..f4b3e533 100644 --- a/gns3server/modules/vmware/__init__.py +++ b/gns3server/modules/vmware/__init__.py @@ -540,7 +540,13 @@ class VMware(BaseManager): """ if sys.platform.startswith("win"): - return os.path.expandvars(r"%USERPROFILE%\Documents\Virtual Machines") + from win32com.shell import shell, shellcon + documents_folder = shell.SHGetSpecialFolderPath(None, shellcon.CSIDL_PERSONAL) + windows_type = sys.getwindowsversion().product_type + if windows_type == 2 or windows_type == 3: + return '{}\My Virtual Machines'.format(documents_folder) + else: + return '{}\Virtual Machines'.format(documents_folder) elif sys.platform.startswith("darwin"): return os.path.expanduser("~/Documents/Virtual Machines.localized") else: