I’m building a .hta (with javascript) from which i want to launch several applications.
But when i execute my .hta i get the error message can’t find file
this is the code:
<script type="text/javascript" language="javascript">
function RunFile(path) {
var relpath = window.location.href;
var fullpath = relpath + path;
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run(fullpath, 1, false);
}
RunFile("\file.exe");
</script>
window.location.hrefincludes filename and protocol too. Try this:Notice use of
/instead\, and it’s also handy to end uprelpathwith/, so you don’t need to add it to function argument.EDIT
I’m not sure what you mean with getting location without file, maybe this (citation from Windows Sripting Technologies (unfortunately broken now):
The active process is for example the running HTA, so this will give the local path of the HTA file (without filename).
currentDirectoryis a property ofWScript.Shell, so you can use it withWshShellin your code, also to set working directory.