You could extract the correct path from window.location.pathname
, and then set the value to CurrentDirectory
. I've used something like the code below:
var shell = new ActiveXObject('WScript.Shell'),
defaultInstallationFolder = 'installation_folder_name',
currentPath = window.location.pathname.replace(/\\/g,'/'),
defaultRootPath;
if (currentPath.charAt(0) === '/') { // For the browser environment
currentPath = currentPath.substring(1, currentPath.length);
}
currentPath = currentPath.split(defaultInstallationFolder);
defaultRootPath = currentPath[0] + defaultInstallationFolder;
shell.CurrentDirectory = defaultRootPath;
IE and HTA give a slightly different pathname
(in IE it starts with /
). Sometimes it's nice to debug a HTA in IE, hence the check for currentPath
.