WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Win8

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Run HTA File Problem

 Keywords: HTML application .HTA  

Question:

I have a script that launches an HTML application (.HTA) using RunShell(). It is working fine under Windows XP, Vista and 7, but no longer under Windows 8.

I did some testing using different ways to call the application:

Test #1 : run(myHTAfile, '')
Test #2 : runwait(myHTAfile, '')
Test #3 : procid = RunShell(myHTAfile, "", "", @NORMAL, @GETPROCID)
Test #4 : ShellExecute(myHTAfile, "", "", @NORMAL, "")
Only Test #4 sucessfully launches the application.

Has anyone encountered such problems?

I could use ShellExecute but would be stuck without any "wait" option...

Answer:

Shellexecute uses a slightly different method to launch applications. I suspect ShellExecute works because the shell sits in a much higher layer in the OS and consequently is able to take a dependency on elevation.

Apparently MSFT changed the registry entries for '.hta' files a bit, by adding a couple of additional parameters to the shell\open\command key. Of course WinBatch will faithfully use those parameters when it attempts to start mshta.exe. Not sure what MSFT intended but the parameters do appear to have an untoward effect on running the exe as a desktop application. It appears to be an isolated problem but we will have to look into this a bit further. Here atre some possible alternate solutions:

Option 1: Use ShellExecute then a WinWaitClose to handle the wait.

Option 2: Run mshta.exe and pass the htafile as parameter.

Run("mshta.exe", myHTAfile)
RunWait("mshta.exe", myHTAfile)
RunShell("mshta.exe", myHTAfile, "", @NORMAL, @GETPROCID)

Article ID:   W18444
Filename:   Run HTA File Problem.txt
File Created: 2012:11:26:09:49:54
Last Updated: 2012:11:26:09:49:54