Executing 32bit and 64bit mshta.exe (bypass default handler)

20,986

Maybe it's a OS version issue (?) I can't tell, as your test run as expected on my XP x64.

[EDIT] The code I run:

Rem run32.bat
%WinDir%\SysWOW64\mshta.exe c:\page.hta

Rem run64.bat
%WinDir%\System32\mshta.exe c:\page.hta

Here is what I get: test screenshot

Share:
20,986
TJR
Author by

TJR

Software Developer in Austin, TX specializing in scalable software.

Updated on March 25, 2020

Comments

  • TJR
    TJR over 4 years

    I'd like to be able to launch a page.hta in 32bit and 64bit versions of the mshta.exe.

    Create the file c:\page.hta

    <body onclick="if(confirm('Close? (onclick)')){self.close();}">
    <h1>Test Page</h1>
    <script type="text/javascript">
    var elem = [
      "UserAgent="+window.navigator.userAgent,
      "Platform="+window.navigator.platform
    ];
    var taBegin = "<textarea style='width:100%' rows='"+((elem.length+1)*1.5)+"'>";
    var taEnd = "</textarea>";
    document.write(taBegin+elem.join("\n")+taEnd);
    </script>
    </body>
    

    Now here is the batch file to attemp to load the page differently.

    @echo off
    rem Launch 32bit
    c:\Windows\SysWOW64\mshta.exe c:\page.hta
    
    rem Launch 64bit
    c:\Windows\System32\mshta.exe c:\page.hta
    

    Another interesting thing, try changing the default handler to notepad for .hta files. If you execute the previous commands, and it launches notepad. It appears that mshta has some logic that only launches the .hta via the default handler.

    Whatever command is specified as the default handler is used.