James-Jesse Drinkard
James-Jesse Drinkard

Reputation: 15703

How do I make a direct link to execute an .hta file?

I have an .hta file on a mapped drive that I can manually navigate to, double-click on the .hta file and it executes fine. However, I added a link to the full path on the share (from an IE 8 page) and when I try to run it from the link, as in:

Q:\path...\.hta

Then I get a javascript error an error occurred in running the script "length is null or not an object". The javascript code is coming from the .hta file itself on this line:

...
for (var i = 0; i < matches.length; i++) { 
...

I'm guessing that for some reason "i" isn't initialized when the .hta is run off the link, rather than manually.

In any event, when I try to directly go to the file from the link, I do get a dialog asking if I want to run, save, or cancel the .hta file. When I try to run it, I get the javascript error.

So my questions are:

  1. how do I run this .hta file from a browser link?
  2. why do I get the javascript error when run from a link and not when it's run manually?

Upvotes: 0

Views: 1910

Answers (1)

Teemu
Teemu

Reputation: 23396

HTA does not recognize mapped drives.

I assume you have your application saved at server, and then you run it at workstation, where you have this mapped driver Q as a shortcut to the server.

The correct path to server is something like this:

//Your_Server_Name/path_in_server/file.hta

An actual IP can also be used instead of the Your_Server_Name.

To run the HTA in browser (IE only) without prompts, you'll need to change many settings in Intranet zone security- and Advanced-tab to very insecure mode.

About the error message:

It seems, that matches has not a property named length. If matches is defined, it's probably a number or a boolean, or some other type of object which has not the length property.

If the message is something like this: Can't get the property length: object is null or not defined. This means, that matches is undefined.

Notice, that HTA is an independent application with it's own top.window, and it can't interact with the browser window. (There is no way to refer the opener in HTA, if the opener is a browser window.)

Upvotes: 1

Related Questions