locked
vbscript errors not being captured in .hta files RRS feed

  • Question

  • I am having an issue with running .hta files which contain vbscript errors (such as missing Dim statements when using OPTION EXPLICT).

    On my Windows 10 PC I get message saying "Do you want to continue running scripts on this page?" but on my Windows 7 PC the message does not appear but the .hta misbehaves (of course).

    I assume it has something to do with "just in time debugging" but don't know how to resolve it.

    Unchecking the "Disable script debugging" settings in the IE Internet Options has not effect.

    Any suggestions?

    Monday, March 19, 2018 11:29 AM

Answers

  • I went thru the whole scenario again and it worked until I rebooted.

    So I tried checking both IE Advanced settings

    1. Disable script debugging (Internet Explorer)
    2. Disable script debugging (Other)

    Now I get a script error dialog popup for both versions of mshta.exe and the problem is resolved 


    • Marked as answer by MicroZapman Tuesday, March 20, 2018 3:12 AM
    • Edited by MicroZapman Tuesday, March 20, 2018 3:13 AM
    Tuesday, March 20, 2018 3:12 AM

All replies

  • HTA files cannot be run in IE.  Without the code lines and full error message there is no way to even guess at your issue.

    Option Explicit is not valid in IE files


    \_(ツ)_/

    Monday, March 19, 2018 11:34 AM
  • I am talking about a .hta file which allows "Option Explicit"

    When I run it this way, I get a Script Error dialog popup saying a "variable is undefined

    C:\>c:\Windows\System32\mshta.exe c:\inv.hta

    but running it this way does not...

    C:\>c:\Windows\syswow64\mshta.exe c:\inv.hta

    Monday, March 19, 2018 12:01 PM
  • I have some hta files which create 32-bit objects like:

    1. a DLL I created in VB6 which uses comdlg32.dll to let me open a File open/save dialog box in .vbs or .hta files
    2.  ADODB.CONNECTION for MS Access databases     
          set cn = CreateObject("ADODB.Connection")
          cn.Provider = "Microsoft.Jet.OLEDB.4.0"
          cn.Properties("Data Source") = dbpath

    These will not run using the 64-bit version of mshta.exe (C:\windows\system32\mshta.exe) but work fine using the 32-bit version C:\windows\syswow64\mshta.exe

    Under Windows 7 any vbscript errors are ignored under the 32-bit version but under Windows 10 the script error dialog appears.

    Executing "ftype htafle" returns 
    Windows 7:   htafile=C:\Windows\SysWOW64\mshta.exe "%1" %* for Windows 7
    Windows 10: htafile=C:\Windows\SysWOW64\mshta.exe "%1" {1E460BD7-F1C3-4B2E-88BF-4E770A288AF5}%U{1E460BD7-F1C3-4B2E-88BF-4E770A288AF5} %*

    Oddly, double clicking .hta files under Windows 10 works whether 32-bit objects are used or not.
    It seems it accommodates either somehow
    Searching the Win10 registry for 1E460BD7-F1C3-4B2E-88BF-4E770A288AF5 finds only the htafile setting - no CLSID entry !?!?

    Similarly I have to create shortcuts for some .vbs files since the 64-bit version of wscript.exe
    is associated with .vbs files

    vbsfile="%SystemRoot%\System32\WScript.exe" "%1" %*

    I can deal with these situations except the part where vbscript errors are ignored under the 32-bit version of mshta.exe


    Monday, March 19, 2018 3:11 PM
  • If a COM component is only available in a 32-bit version, then you must run the 32-bit version of mshta.exe. There's no way around that.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 19, 2018 3:53 PM
  • If a COM component is only available in a 32-bit version, then you must run the 32-bit version of mshta.exe. There's no way around that.


    -- Bill Stewart [Bill_Stewart]

    Thanks Bill - I understand that.

    What I don't understand is why vbscript errors, even syntax errors, are not detected/flagged by the 32-bit version of mshta.exe on Windows7...

    Monday, March 19, 2018 4:26 PM
  • Sorry, I can't reproduce that.

    I would recommend transitioning away from HTAs as soon as possible, as they are essentially obsolete.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 19, 2018 5:08 PM
  • I am talking about a .hta file which allows "Option Explicit"

    When I run it this way, I get a Script Error dialog popup saying a "variable is undefined

    C:\>c:\Windows\System32\mshta.exe c:\inv.hta

    but running it this way does not...

    C:\>c:\Windows\syswow64\mshta.exe c:\inv.hta

    VBScript in an HTA is not th same VBScript run under WSH in a VBS file.  It is the HTML version of VBScript and does not support Option Explicit.

    Option Explicit will cause an error trap.  It will abort a script with a parse error when used in VBS.


    \_(ツ)_/

    Monday, March 19, 2018 6:29 PM
  • I am talking about a .hta file which allows "Option Explicit"

    When I run it this way, I get a Script Error dialog popup saying a "variable is undefined

    C:\>c:\Windows\System32\mshta.exe c:\inv.hta

    but running it this way does not...

    C:\>c:\Windows\syswow64\mshta.exe c:\inv.hta

    VBScript in an HTA is not th same VBScript run under WSH in a VBS file.  It is the HTML version of VBScript and does not support Option Explicit.

    Option Explicit will cause an error trap.  It will abort a script with a parse error when used in VBS.


    \_(ツ)_/

    Option Explicit certainly does work in a .hta file.  

    Even syntax errors are not being trapped in the 32-bit mshta. 

    I changed a Dim to Dimx and still no script error dialog box...

    Monday, March 19, 2018 7:02 PM
  • Option Explicit certainly does work in a .hta file.  

    Even syntax errors are not being trapped in the 32-bit mshta. 

    I changed a Dim to Dimx and still no script error dialog box...

    If you do not call the script function  or form event you will not get any error.

    Without an actual scrip example it is not possible to understand what you are seeing.


    \_(ツ)_/

    Monday, March 19, 2018 7:08 PM
  • Ok.  If we place the Option Explicit in the correct location and design the script correctly it works on both 32 bit and 64 bit versions.

    Try this to see what I have done.

    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>My HTML Application</title>
    <script language="vbscript">
    <!-- Insert code, subroutines, and functions here -->
    
    </script>
    <hta:application
    	applicationname="MyHTA"	
    	border="dialog"
    	borderstyle="normal"
    	caption="My HTML Application"
    	contextmenu="no"
    	icon="myicon.ico"
    	maximizebutton="no"
    	minimizebutton="yes"
    	navigable="no"
    	scroll="no"
    	selection="no"
    	showintaskbar="yes"
    	singleinstance="yes"
    	sysmenu="yes"
    	version="1.0"
    	windowstate="normal"
    >
    </head>
    <script type="text/vbscript">
    
    Option Explicit
    Sub window_onload
         i = 0
         window.document.write "hello"
    End Sub
    </script>
    <body>
    <!-- HTML goes here -->
    
    </body>
    </html>
    

    This will throw an error under both 32 bit and 64 bit subsystems on W10 and W2016.

    The following also generates declaration errors in both subsystems:

    <script type="text/vbscript">
    Option Explicit
    i = 99
    </script>
    


    \_(ツ)_/

    Monday, March 19, 2018 7:20 PM
  • That's the same result I get on Win10, but on Win7, I get the error with the 64-bit mshta but not the 32-bit.

    It just opens a blank window and no error.  I'd swear it used to work. 

    I ran sfc /scannow and found no problems.

    Thanks for your efforts to help. I'm still trying to get to the bottom of it.

    My hta file is 687 lines - it opens a SQLite database and lets me view data in various ways.


    • Edited by MicroZapman Tuesday, March 20, 2018 3:23 PM
    Monday, March 19, 2018 8:20 PM
  • Since we cannot reproduce the problem, it is some issue on your system.

    Your question is outside the scope of this forum.


    -- Bill Stewart [Bill_Stewart]

    Monday, March 19, 2018 9:12 PM
  • Since we cannot reproduce the problem, it is some issue on your system.

    Your question is outside the scope of this forum.


    -- Bill Stewart [Bill_Stewart]

    That is what I assumed but I thought someone might have some insight as to whether it is a registry setting, etc or an issue that someone else may have experienced. I have done a lot of searching and found no helpful information. Some search results indicate the SYSWOW version is malware - lot's of bad information floating around...


    Monday, March 19, 2018 9:35 PM
  • I have no issues on Win7.

    Your issue is a system problem.  I recommend a system rebuild or contacting MS support for help.


    \_(ツ)_/

    • Marked as answer by MicroZapman Monday, March 19, 2018 11:47 PM
    • Unmarked as answer by MicroZapman Monday, March 19, 2018 11:47 PM
    • Marked as answer by MicroZapman Monday, March 19, 2018 11:48 PM
    • Unmarked as answer by MicroZapman Tuesday, March 20, 2018 1:39 AM
    Monday, March 19, 2018 9:41 PM
  • jrv,

    Thanks for trying that on Win7 - I appreciate it.  A system rebuild takes forever and I never get everything back the way I want it.

    My hta programs all work - this issue just makes it hard to debug if I mistype something. 

    I'll just copy over to Win10, clean them up and copy them back if I can't resolve the issue.

    Thanks for your help...

    Monday, March 19, 2018 11:46 PM
  • Believe it or not -> I got it working properly!!!

    I was searching the registry for JTIDEBUG  (Just-In-Time Debugging) and found entries for MSE7.exe.

    It is the Microsoft Script Editor that comes with MS Office. I ran it and messed around a little but didn't really do anything.  It must have set something in the registry because the next time I ran the little hta that jrv was testing with, it popped up a dialog box titled "WEB PAGE ERROR" and asking "Do you want to debug this web page?"

    It had a check box "Use the built in script debugger in Internet Explorer.". 

    It did this for both the 32-bit and 64-bit mshta.exe. It also listed debuggers it could use - one being the Microsoft Script Editor and a checkbox if you always wanted to use it. 

    I kept messing with it and answered No at some point - I don' remember exactly what sequence / order, but now I get the typical Script Error dialog with both versions of mshta.exe.

    Dumb luck but I'm satisfied!




    • Edited by MicroZapman Tuesday, March 20, 2018 2:01 AM
    • Marked as answer by MicroZapman Tuesday, March 20, 2018 2:02 AM
    • Unmarked as answer by MicroZapman Tuesday, March 20, 2018 2:38 AM
    Tuesday, March 20, 2018 1:59 AM
  • Debugging is controlled by the IE Advanced settings for the debugger.  

    \_(ツ)_/

    Tuesday, March 20, 2018 2:06 AM
  • Debugging is controlled by the IE Advanced settings for the debugger.  

    \_(ツ)_/

    I had unchecked "Disable script debugging (Internet Explorer)" early on in an effort to fix the problem but it is checked again now. It seems running the MSE7.exe program triggered the eventual resolution...

    Damn! I rebooted and now it's broke again!!!!!!

    • Edited by MicroZapman Tuesday, March 20, 2018 2:38 AM
    Tuesday, March 20, 2018 2:33 AM
  • I went thru the whole scenario again and it worked until I rebooted.

    So I tried checking both IE Advanced settings

    1. Disable script debugging (Internet Explorer)
    2. Disable script debugging (Other)

    Now I get a script error dialog popup for both versions of mshta.exe and the problem is resolved 


    • Marked as answer by MicroZapman Tuesday, March 20, 2018 3:12 AM
    • Edited by MicroZapman Tuesday, March 20, 2018 3:13 AM
    Tuesday, March 20, 2018 3:12 AM