通过 HTML 文件中的链接打开 exe 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4252913/
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
Open an exe file through a link in a HTML file?
提问by Mohammad Dayyan
I want to open an exe file through a link in an HTML file.
我想通过 HTML 文件中的链接打开一个 exe 文件。
Is it possible? If so, how?
是否可以?如果是这样,如何?
采纳答案by RDL
You can not start/execute an .exe file that resides locally on the users machine or through a site. The user must first download the exe file and then run the executable.
您无法启动/执行驻留在用户计算机本地或通过站点的 .exe 文件。用户必须首先下载 exe 文件,然后运行可执行文件。
回答by mcd
You can do this
你可以这样做
it's the only way I see:
这是我看到的唯一方式:
<html>
<head>
<title>Open exe</title>
<script type="text/javascript">
function runProgram()
{
var shell = new ActiveXObject("WScript.Shell");
var appITunes = "\"C:\Program Files\iTunes\iTunes.exe\" ";
shell.Run(appITunes);
}
</script>
</head>
<body>
<a href="javascript:runProgram()">Run program</a>
</body>
</html>
回答by Mahfoud Boukert
On a local computer you can do it with ease, So you have just to Create your own custom protocol, like the one used by Skype or iTunes to launch their native windows applications : - Custom protocol has to be created on Windows Registry by adding a entry as the one here :
在本地计算机上,您可以轻松完成,因此您只需创建自己的自定义协议,例如 Skype 或 iTunes 用于启动其本机 Windows 应用程序的协议: - 必须在 Windows 注册表上添加自定义协议作为此处的条目:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ACCapp]
@="URL:ACCapp Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\ACCapp\shell]
[HKEY_CLASSES_ROOT\ACCapp\shell\open]
[HKEY_CLASSES_ROOT\ACCapp\shell\open\command]
@="msaccess.exe"
the word in Blod ACCappis the name of the custom protocol that would be used on your html href link as follow
Blod ACCapp 中的单词是将在您的 html href 链接上使用的自定义协议的名称,如下所示
<a href="ACCapp://">PLEASE RUN MS Access exe file</a>
回答by Wouter Dorgelo
Due security reasons it's not possible, and probably it's better it stays that way.
由于安全原因,这是不可能的,而且最好保持这种状态。
The following code works, but only on the machine which the program exists on:
以下代码有效,但仅适用于该程序所在的机器:
<a href = "c:\Myfolder\Myprogram.exe">
回答by Wouter Dorgelo
You could write an Active-X object that runs in internet explorer only.
您可以编写仅在 Internet Explorer 中运行的 Active-X 对象。
It's not an exe but it's the closest you'll get to running an exe.
它不是 exe,但它是您最接近运行 exe 的方法。
回答by samplist
I created an application for this exact purpose. It is called WebRun and you can download it from www.webrunapps.com. After installation you can create a webrun link to launch any executable / file / command on your Windows PC. Here is an example to run notepad:
我为此确切目的创建了一个应用程序。它被称为 WebRun,您可以从www.webrunapps.com下载它。安装后,您可以创建一个 webrun 链接以在您的 Windows PC 上启动任何可执行文件/文件/命令。这是运行记事本的示例:
<a href="webrun:C:\Windows\notepad.exe">Notepad</a>
Hope that helps.
希望有帮助。
回答by Greg Simonis
At work I'm a PC (bummer - I'm a MAC fanatic) and Firefox. The code that worked for me in Firefox, and the link works internally ONLY, was <a href = "file:///c:/Myfolder/Myprogram.exe">
.
在工作中,我是 PC(无赖 - 我是 MAC 狂热者)和 Firefox。在 Firefox 中对我有用的代码,并且该链接仅在内部有效,是<a href = "file:///c:/Myfolder/Myprogram.exe">
.
AND it works ONLY if you right click on the link and select Open Link in Ext.App. Just clicking on the link itself prompts the user to save the .exe file and then run it.
并且仅当您右键单击该链接并选择在 Ext.App 中打开链接时它才有效。只需单击链接本身就会提示用户保存 .exe 文件,然后运行它。
I could not get it 2 work in IE or Firefox with just <a href = "c:/Myfolder/Myprogram.exe">
我无法在 IE 或 Firefox 中使用它 2 <a href = "c:/Myfolder/Myprogram.exe">
回答by Jonathan J. Pecany
I know a good answer to this one, Roblox and Atom uses this technique to run exe programs with a link. I have never done this so I can't really explain how to do it but I know how. They use URI protocols. URI protocols are like http, ftp, and https. I don't know Roblox's uri protocol, but I know Atoms, atom's is atom://. I recently just learned of this type of technology so I don't know much about it.
我知道一个很好的答案,Roblox 和 Atom 使用这种技术来运行带有链接的 exe 程序。我从来没有这样做过,所以我无法真正解释如何去做,但我知道怎么做。他们使用 URI 协议。URI 协议类似于 http、ftp 和 https。我不知道 Roblox 的 uri 协议,但我知道 Atoms,atom 是 atom://。我最近才知道这种类型的技术,所以我对它了解不多。
Except, the user must first download the exe files first, than once download, if the uri protocol is set on it, you can open it through a link.
除此之外,用户必须先下载exe文件,而不是一次下载,如果上面设置了uri协议,您可以通过链接打开它。
If you have atom installed on your system, here is an example, it will open the program which as I believe is a exe file. This is just a random package I stumble a bond. atom://settings-view/show-package?package=autocomplete-plus
如果你的系统上安装了 atom,这里有一个例子,它会打开我认为是一个 exe 文件的程序。这只是我偶然发现的一个随机包裹。atom://settings-view/show-package?package=autocomplete-plus
Mahfoud Boukert actually explains this a bit, with some code examples.
Mahfoud Boukert 实际上解释了这一点,并附有一些代码示例。
回答by illusionninja
I know a good answer to this one, Roblox and Atom uses this technique to run exe programs with a link.
我知道一个很好的答案,Roblox 和 Atom 使用这种技术来运行带有链接的 exe 程序。
itch.iois another website that can emulate an .exe file but doesn't require you to download it. Take for example, https://danidev.itch.io/triangle-game, by Dani (a youtuber that i quite like :D). I'm too lazy to dig through file sources but basically, this game was created with Unity. I'm not too sure of this but I think to have an .exe file load on an .html website, you have to use WebGL. (because it was the only option i found when digging through one of Dani's videos that supported exporting a Unityprogram to HTML5)
itch.io是另一个可以模拟 .exe 文件但不需要您下载它的网站。以https://danidev.itch.io/triangle-game为例,作者是 Dani(我非常喜欢 :D 的 youtuber)。我懒得去挖掘文件源,但基本上,这个游戏是用Unity创建的。我对此不太确定,但我认为要在 .html 网站上加载 .exe 文件,您必须使用 WebGL。(因为这是我在挖掘支持将Unity程序导出到HTML5的 Dani 视频之一时找到的唯一选项)
回答by Anshul
Why not use CGI for this purpose, CGI actually runs the executable through browser on server.
为什么不为此使用 CGI,CGI 实际上通过服务器上的浏览器运行可执行文件。