Html 如何制作指向本地可执行文件的超链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2815982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:03:41  来源:igfitidea点击:

How do I make a hyperlink to a local executable?

htmlexecutablehyperlink

提问by Scott Ferguson

We have an Intranet website, and a WPF windows executable installed on every workstation.

我们有一个 Intranet 网站,并在每个工作站上安装了 WPF Windows 可执行文件。

  1. How can we create a hyperlink on the intranet website that will launch the locally installed executable?
  2. Ideally we want the launch to be seamless. Is there a way of setting the browsers trust settings so that it won't display a security warning dialog for this executable?
  1. 我们如何在 Intranet 网站上创建一个超链接来启动本地安装的可执行文件?
  2. 理想情况下,我们希望发布是无缝的。有没有办法设置浏览器信任设置,以便它不会显示此可执行文件的安全警告对话框?

We have full admin capabilities on each workstation, and each user only uses Internet Explorer. We also know the correct local path for the exe.

我们在每个工作站上都​​有完整的管理功能,每个用户只使用 Internet Explorer。我们还知道 exe 的正确本地路径。

Update: We tried this anchor tag, but when we click on it, we get no response:

更新:我们尝试了这个锚标记,但是当我们点击它时,我们没有得到响应:

<a href="c:\Flipper\Splash.Flipper.exe">Click Here</a>

We have also tried this via Google Chrome, and we get the same (lack of) response. Clicking the link causes nothing to happen.

我们也通过谷歌浏览器尝试过这个,我们得到了相同的(缺乏)响应。单击链接不会导致任何事情发生。

采纳答案by Henning

If your users really use only IE you can use this snippet:

如果您的用户真的只使用 IE,您可以使用以下代码段:

<script type="text/javascript">
    function runNotepad() {
        var Shell = new ActiveXObject("WScript.Shell");
        Shell.Run("%WINDIR%\notepad.exe");
    }
</script>
<a href="#" onclick="runNotepad(); return false;">Run Notepad</a>

However, with any sensible security settings this leads to an awful lot of warnings (and rightfully so!).

然而,任何合理的安全设置都会导致大量警告(理所当然!)。

回答by Jage

If you know the path for the file and it's the same on every machine, you can link to the local path:

如果您知道文件的路径并且它在每台机器上都相同,则可以链接到本地​​路径:

<a href="C:\Windows\prog.exe">Click Here</a>

We did this at a previous company on our intranet. Worked, no problem.

我们在我们的 Intranet 上的一家以前的公司中做到了这一点。工作了,没问题。

回答by Zachary

I have links to UNC folders/files inside my intranet portal and I've found that the clients need to have the local domain name "mycompany.local" added in their "Trusted Sites". I have also found this only works in IE (verified not working in FireFox and Safari).

我在 Intranet 门户中有指向 UNC 文件夹/文件的链接,我发现客户需要在其“受信任的站点”中添加本地域名“mycompany.local”。我还发现这仅适用于 IE(经验证在 FireFox 和 Safari 中无效)。

回答by Marko

Use the file:/// prefix.

使用 file:/// 前缀。

Like so:

像这样:

<a href="file:///C:/Windows/notepad.exe">asd</a>

I'm not sure if you'll be able to get past the security dialog though (open, save, cancel).

我不确定您是否能够通过安全对话框(打开、保存、取消)。