Open program from HTA RRS feed

  • Question

  • Hello

    Im trying to create a HTA application, that can open programs(exe, bat etc..) locally on the computer.

    This will be used on a Kiosk PC, where the users don't have access to the desktop etc.

    But have some problems with finding a script that works with my existing code..

    Right now I'm using this script to open the programs:

    <script type="text/javascript">
        function runApp(which) {
        WshShell = new ActiveXObject("WScript.Shell");
        WshShell.Run (which,1,true);

    And this is how my links looks:

    style="cursor: hand; display: block;">Start Program

    The problem with this script, is that some of the programs I open from the launcher HTA, are placed below the HTA app that runs in fullscreen.. So the users need to ALT+TAB to switch to them.. This not is not good, since most of the users don't know what to do..

    I have then been searching for another script, and found this HTA sample, which looks like a better way to do it:

    <!DOCTYPE html>
    <meta http-equiv="X-UA-Compatible" content="IE=9">
    APPLICATIONNAME="Open link with chrome browser"
    <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
    <title>Test HTA</title>
    Option Explicit
     Function Executer(StrCmd)
     Dim ws,MyCmd,Resultat
     Set ws = CreateObject("wscript.Shell")
     MyCmd = "CMD /C " & StrCmd & " "
     Resultat =,0,True)
     Executer = Resultat
    End Function
    Sub window_onload()
     CenterWindow 400,320
    End Sub
    Sub CenterWindow(x,y)
     Dim iLeft,itop
     window.resizeTo x,y
     iLeft = window.screen.availWidth/2 - x/2
     itop = window.screen.availHeight/2 - y/2
     window.moveTo ileft,itop
    End Sub
    <p>Links :</p>
    <li><a href="#" onClick="Call Executer('Start C:\ScriptExe.exe')">EXE test</a></li>
    <li><a href="#" onClick="Call Executer('Start C:\Tools\Bats\menu.bat')">Bat test</a></li>
    <li><a href="#" onClick="Call Executer('Start chrome.exe chrome --app=')">Chrome App Test</a></li>

    The problem with the script, is that I need to use:

    <meta http-equiv="X-UA-Compatible" content="IE=9">

    My existing code only works with IE=9 and breaks alot of things like jquery, if i dont have that tag..

    And If I add the tag to the sample above, it breaks and show me this error when I run the HTA:

    An error has occured in the script on this page. Line: 46 Char: 31 Error: Expected ";" Code: 0

    So looks like something breaks, with this linie and char 31 is: Call Executer

    <li><a href="#" onClick="Call Executer('Start C:\ScriptExe.exe')">EXE test</a></li>

    I have no prior experience with hta, vbs and only a little java.. So I have been using whatever scripts I'm able to find to build this.

    Can anyone tell me, why this don't work with IE=9 content tag? Or perhaps know a better way of doing this?

    Thursday, October 10, 2019 9:38 AM