简体   繁体   English

如何建立直接链接以执行.hta文件?

[英]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. 我在映射驱动器上有一个.hta文件,可以手动导航到该文件,双击.hta文件,它可以正常执行。 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: 但是,我添加了指向共享的完整路径的链接(来自IE 8页面),并且当我尝试从链接中运行它时,如下所示:

Q:\\path...\\.hta 问:\\ path ... \\。hta

Then I get a javascript error an error occurred in running the script "length is null or not an object". 然后,我得到一个JavaScript错误,在运行脚本“长度为null或不是对象”时发生错误。 The javascript code is coming from the .hta file itself on this line: javascript代码来自.hta文件本身,位于此行:

...
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. 我猜测由于某些原因,.hta在链接之外运行时不会初始化“ i”,而不是手动进行。

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. 无论如何,当我尝试直接从链接转到文件时,确实会出现一个对话框,询问我是否要运行,保存或取消.hta文件。 When I try to run it, I get the javascript error. 当我尝试运行它时,出现了JavaScript错误。

So my questions are: 所以我的问题是:

  1. how do I run this .hta file from a browser link? 如何从浏览器链接运行此.hta文件?
  2. why do I get the javascript error when run from a link and not when it's run manually? 为什么从链接运行而不是手动运行时出现javascript错误?

HTA does not recognize mapped drives. HTA无法识别映射的驱动器。

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. 我假定您已将应用程序保存在服务器上,然后在工作站上运行该应用程序,在该工作站上,此映射的驱动程序Q作为服务器的快捷方式。

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 . 也可以使用实际IP代替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. 要在没有提示的情况下在浏览器(仅IE)中运行HTA,您需要将Intranet区域“安全性”和“高级”选项卡中的许多设置更改为非常不安全的模式。

About the error message: 关于错误消息:

It seems, that matches has not a property named length . 看来, matches没有一个名为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. 如果定义了matches ,则可能是数字或布尔值,或者是其他没有length属性的对象。

If the message is something like this: Can't get the property length: object is null or not defined . 如果消息是这样的: Can't get the property length: object is null or not defined This means, that matches is undefined. 这意味着, matches是不确定的。

Notice, that HTA is an independent application with it's own top.window , and it can't interact with the browser window. 注意,HTA是一个独立的应用程序,具有自己的top.window ,并且无法与浏览器窗口进行交互。 (There is no way to refer the opener in HTA, if the opener is a browser window.) (如果打开程序是浏览器窗口,则无法在HTA中引用该opener 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM