如何使用来自 url 或本地文件的 javascript 在 html 中运行 exe

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14398602/
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-10-26 21:31:43  来源:igfitidea点击:

How to run an exe in html using javascript from a url or local file

javascripthtmlfile

提问by user1990312

I would like to run an .exe file from the browser I've tried using the iframe command and but can't seem to get this to work all I want is every time someone goes on to the intranet (not the internet) is this possible?

我想从浏览器运行一个 .exe 文件我已经尝试使用 iframe 命令,但似乎无法让它工作我想要的是每次有人进入内联网(而不是互联网)是这个可能的?

Ok I've been researching this for a while, I understand the implications of doing something like this.

好的,我已经研究了一段时间,我理解做这样的事情的含义。

The only reason why I want to do it like this is because I want some updates to run whenever someone goes on the homepage of the intranet such as java, flash etc... is there a possible way to do this with minimal user interaction?

我想要这样做的唯一原因是因为我希望每当有人进入内部网的主页时运行一些更新,例如 java、flash 等......是否有可能以最少的用户交互来做到这一点?

回答by svineet

There is no standard way of running executables. You can only execute .exe in IE through ActiveX. Doing it in IE

没有运行可执行文件的标准方法。您只能通过 ActiveX 在 IE 中执行 .exe。在 IE 中执行

Javascript to execute the .exe when the webpage loads -

网页加载时执行 .exe 的 Javascript -

window.onload = function(){
  if (!document.all) {
  alert ("Available only with Internet Explorer.");
  return;
  }
  var ws = new ActiveXObject("WScript.Shell");
  ws.Exec("C:\Program Files\Adobe\Photoshop 6.0\Photoshp.exe");
}

回答by GitaarLAB

Change their shortcut to their browser (that is sure a lot easier than prepping a special image or pdf file or god knows what).

更改浏览器的快捷方式(这肯定比准备特殊图像或 pdf 文件或天知道要容易得多)。

Point the users browser-shortcut to a script, that first runs your exe (and every command you want), then finally start the browser itself. Just (like) a batch-script.

将用户浏览器快捷方式指向一个脚本,该脚本首先运行您的 exe(以及您想要的每个命令),然后最后启动浏览器本身。只是(像)一个批处理脚本。

You are administrator on that corporate network right? Should be easy to do then.
Ofcourse you could als push the updates you want on your network, then you wouldn't need such a solution at all!

你是那个公司网络的管理员吧?那么应该很容易做到。
当然你也可以在你的网络上推送你想要的更新,那么你根本不需要这样的解决方案!

Good luck!

祝你好运!