HTA's; use other browser to host?

12,304

Solution 1

You can't.

There is a similar Mozilla project named XULRunner, but HTA only works in Internet Explorer - the two technologies aren't compatible.

To make this clear: HTA will probably not work in anything that's not IE. Yes, HTA is a browser control in a window, but it also has normal aplication privileges (i.e. filesystem access, registry, arbirary code execution etc.). When running in a browser, these privileges are denied (for good reasons - you don't want just any webpage to read your files).

So, launching the HTA in a browser will work, but any interaction with the local system will fail, which negates the whole idea. Launching a HTA in XULRunner will also fail, because XULRunner uses a completely different API.

The only scenario that could possibly work is this: a webapp which doesn't use any of the HTA-specific or XULRunner-specific API (i.e. behaves like a normal browser app). In such case, your app might work with HTA, XULRunner, as well as in any browser. Incidentally, this would take away any advantage of using HTA and introduce masive security holes because of the higher privileges; you'd be better off with using Google Chrome or Mozilla Prism for that.

(We've been trying to find a cross-browser solution for some time, and HTA is definitely not it)

Solution 2

I was tackling the related task of running hta's from various browsers. I've put my findings here for anybody else who is trying to do that and finds this question.

You can run hta's from several browsers, using the same mshta executable that IE uses. You need fully qualified URI's in your hta code, which isn't needed from IE.

Today (2011-02-01) I tried using hta's from Firefox (3.6.13), Opera 11 and Safari for Windows 5.0.3.

After some teething problems in Firefox I got hta's to work from those browsers. (In all cases these use the same mshta executable that IE uses. This is not hta's running in other browsers, but running hta's from other browsers. This might suit your purposes.)

The hta started desktop applications on my machine (as it does from IE).

The experience wasn't perfect. For IE I set root relative paths in the hta. For the other browsers you can't do that. You need to set fully qualified URI's for things like images, referenced hta's and icons.

So after a little editing I have the hta's working from 4 browsers (IE 8, FF 3, Opera 11 and Safari 5 (Windows)).

(Quick snapshot of that. I'm running hta's from a web server on the local machine. (I have no plans to run them from remote sites.) This allows my workflow to go from browser to desktop more smoothly. The hta's fire up local applications that do things like edit web pages (including the hta's themselves), validate those pages and fire up IDE's. Bridging the gap between browser and desktop apps. has been a liberating experience. I recommend it!)

Notes:

  1. The Firefox development team have notes about enabling hta's which encouraged me to continue after initial failure.
  2. To achieve this in Firefox configuration I set HTML applications to run under mshta.exe (called Microsoft HTML Application Host, in the combo box). Initially that didn't work. I selected "other" picked the same application by hand. That worked, though I have two identical looking entries! You need mshta.exe on your machine to run for any browser. I assume the normal way to install mshta is with IE. (mshta is essentially a modified version of IE, possibly not the current version!)
  3. The Firefox developers have marked this as a strategic effort to dislodge IE from the Enterprise. Their implementation (and Opera's) force you to use fully qualified URI's but apart from that the hta's work as expected.
  4. Firefox seems to cache old versions of the hta's, and doesn't download new ones, though it appears to download something! You might need to clear the cache during development.
  5. My first attempt to do it with Chrome was not successful. Further investigation suggests Chrome doesn't have a native interface for invoking other processes, based on their file extension.

Solution 3

It isn't so much that IE hosts anything, but that mshta.exe hosts components it shares with IE. MSHTA is a script host, much as CScript and WScript are. While IE is also a script host (in the strictest sense) its primary purpose is to be a Web browser.

The Mozilla project mentioned previously is the closest alternative I have found that is based on a browser's innards.

Other script hosts exist for windows too. One of these is NS Basic/Desktop but it is based on standard Windows controls, not browser rendering and an HTML DOM.

Solution 4

Just to be clear: It is not IE nor MSHTMA that really renders a webpage. The rendering thing is partly build into the OS. Thus, things like Active Desktop (does anybody remember that XP thing?) or .HTA or .CHM work without IE. It's just the same way to recognise some HTML things.

Share:
12,304
Admin
Author by

Admin

Updated on June 14, 2022

Comments

  • Admin
    Admin almost 2 years

    If Microsoft's method for using IE as a local host for HTA's then, can I use any other browser instead?

  • Rich Lysakowski PhD
    Rich Lysakowski PhD over 4 years
    This seems like the best answer as of January 6, 2020. You can't run mshta.exe applications with Google Chrome or the newer node.js, V8-based browser engines. The answer by @Mike Gale is nice for background, but doesn't provide the short answer... You can't use Chrome to open and run .hta applications. Here's the page with one of the most updated description of the problem, and modern alternatives. stackoverflow.com/questions/10619990/…
  • Javad Bayat
    Javad Bayat about 3 years
    I know another scenario that could possibly work: a webapp that uses some HTA-specific API but surrounds the part of its code that uses the API within an if statement that checks whether the app is run as an HTA (i.e. if (navigator.appName == "Microsoft Internet Explorer")). Inside the else statement, it can display an error message like "You can only use this feature when the app is run as an HTA.". In this case, the app might work with HTA, as well as in any other browser, although some of its features won't work.
  • Javad Bayat
    Javad Bayat about 3 years
    Another way to determine if the app is run as an HTA: check the commandLine property of <hta:application> element. If the app is run with mshta.exe, the property will give you a string containing the app's command line. Otherwise, it will give you a value of undefined.