But when i execute my .hta i get the error message can’t find file
this is the code:
window.location.href includes filename and protocol too. Try this:
var relpath = window.location.pathname.replace(/\\/g,'/').split('/'); relpath.pop();// JScript: relpath.length = relpath.length - 1; relpath = relpath.join('/') + '/';
Notice use of
\, and it’s also handy to end up
/, so you don’t need to add it to function argument.
I’m not sure what you mean with getting location without file, maybe this (citation from Windows Sripting Technologies (unfortunately broken now):
"The CurrentDirectory returns a string that contains the fully qualified path of the current working directory of the active process."
The active process is for example the running HTA, so this will give the local path of the HTA file (without filename).
currentDirectory is a property of
WScript.Shell, so you can use it with
WshShell in your code, also to set working directory.