I'm trying to use the following script on various machines, so i need to put in a relative path, if the file is in the same diretory works fine, but if i create a folder in this diretory the code dont recognize the location
<!DOCTYPE html>
<html>
<head>
<hta:application applicationname="WRLK"
id="WRLK"
version="1.0"
innerborder="no"
caption="no"
sysmenu="no"
maximizebutton="no"
minimizebutton="no"
icon="loader2.ico"
scroll="no"
scrollflat="yes"
singleinstance="yes"
showintaskbar="no"
contextmenu="no"
selection="no"
/>
<script type="text/javascript" language="javascript">
function Window_onLoad(){
window.resizeTo(window.screen.availWidth/6.5, window.screen.availHeight/2.143);
window.moveTo(screen.availWidth - (window.screen.availWidth / 6.90) , screen.availHeight - (window.screen.availHeight /1));
}
function CLOSE() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("WIs-1.hta", 1, false);
}
function Trian() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("/WIsWRLK/Triangulacao/trian.hta", 1, false);
}
function nodongle() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("file:///C:/Users/hebert_costa/Downloads/HTA%20WIs/WIsWRLK/nodongle/nodongle.hta", 1, false);
}
this work:
function CLOSE() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("WIs-1.hta", 1, false);
}
but this don't work:
function Trian() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("WIsWRLK/Triangulacao/trian.hta", 1, false);
}
any help?
As per the comment, set the
CurrentDirectoryto the script's directory, which can be obtained fromdocument.URL. Use backslashes in Run commands. See example below.You can create your objects once at the top of the script. You don't have to repeat that code in every function.
Be sure to explicitly set your document mode. The code in the question will, by default, run in IE=7 mode. Since an
hta:applicationsection was included, the highest possible mode, using a single file solution, is IE=9. You can get the benefit of IE=11 mode, while retaininghta:applicationsettings, by splitting your HTA into two files.