Is it possible to run bat/executable file using html5 button event? In IE its achievable using Shell object if I am not wrong.
是否可以使用html5按钮事件运行bat / executable文件?在IE中,如果我没有错,可以使用Shell对象实现。
5 个解决方案
#1
20
Here's what I did. I wanted a HTML page setup on our network so I wouldn't have to navigate to various folders to install or upgrade our apps. So what I did was setup a .bat file on our "shared" drive that everyone has access to, in that .bat file I had this code:
这就是我做的。我想在我们的网络上设置HTML页面,因此我不必导航到各种文件夹来安装或升级我们的应用程序。所以我做的是在我们的“共享”驱动器上设置一个.bat文件,每个人都可以访问,在.bat文件中我有这个代码:
start /d "\\server\Software\" setup.exe
The HTML code was:
HTML代码是:
<input type="button" value="Launch Installer" onclick="window.open('file:///S:Test/Test.bat')" />
(make sure your slashes are correct, I had them the other way and it didn't work)
(确保你的斜线是正确的,我有另一种方式,它不起作用)
I preferred to launch the EXE directly but that wasn't possible, but the .bat file allowed me around that. Wish it worked in FF or Chrome, but only IE.
我更喜欢直接启动EXE,但这是不可能的,但.bat文件允许我解决这个问题。希望它在FF或Chrome中有效,但只有IE。
#2
29
No, that would be a huge security breach. Imagine if someone could run
不,这将是一个巨大的安全漏洞。想象一下,如果有人可以跑
format c:
whenever you visted their website.
每当你访问他们的网站。
#3
18
It is possible when the page itself is opened via a file:///
path.
通过file:///路径打开页面本身是可能的。
<button onclick="window.open('file:///C:/Windows/notepad.exe')">
Launch notepad
</button>
However, the moment you put it on a webserver (even if you access it via http://localhost/
), you will get an error:
但是,当您将它放在Web服务器上时(即使您通过http:// localhost /访问它),您将收到错误:
Error: Access to 'file:///C:/Windows/notepad.exe' from script denied
错误:从拒绝的脚本访问'file:/// C:/Windows/notepad.exe'
#4
4
You can do it on Internet explorer with OCX component and on chrome browser using a chrome extension chrome document in any case need additional settings on the client system!
您可以使用OCX组件在Internet Explorer上执行此操作,在chrome浏览器上使用chrome扩展名chrome文档,无论如何都需要在客户端系统上进行其他设置!
Important part of chrome extension source:
chrome扩展源的重要部分:
var port = chrome.runtime.connectNative("your.app.id");
port.onMessage.addListener(onNativeMessage);
port.onDisconnect.addListener(onDisconnected);
port.postMessage("send some data to STDIO");
permission file:
{
"name": "your.app.id",
"description": "Name of your extension",
"path": "myapp.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://IDOFYOUREXTENSION_lokldaeplkmh/"
]
}
and windows registry settings:
和Windows注册表设置:
HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\your.app.id
REG_EXPAND_SZ : c:\permissionsettings.json
#5
1
You can not run/execute an .exe file that is in the users local machine or through a site. The user must first download the exe file and then run the executable file.
So there is no possible way
您无法运行/执行用户本地计算机或站点中的.exe文件。用户必须首先下载exe文件,然后运行可执行文件。所以没有办法
The following code works only when the EXE is Present in the User's Machine.
以下代码仅在用户机器中存在EXE时有效。
<a href = "C:\folder_name\program.exe">
#1
20
Here's what I did. I wanted a HTML page setup on our network so I wouldn't have to navigate to various folders to install or upgrade our apps. So what I did was setup a .bat file on our "shared" drive that everyone has access to, in that .bat file I had this code:
这就是我做的。我想在我们的网络上设置HTML页面,因此我不必导航到各种文件夹来安装或升级我们的应用程序。所以我做的是在我们的“共享”驱动器上设置一个.bat文件,每个人都可以访问,在.bat文件中我有这个代码:
start /d "\\server\Software\" setup.exe
The HTML code was:
HTML代码是:
<input type="button" value="Launch Installer" onclick="window.open('file:///S:Test/Test.bat')" />
(make sure your slashes are correct, I had them the other way and it didn't work)
(确保你的斜线是正确的,我有另一种方式,它不起作用)
I preferred to launch the EXE directly but that wasn't possible, but the .bat file allowed me around that. Wish it worked in FF or Chrome, but only IE.
我更喜欢直接启动EXE,但这是不可能的,但.bat文件允许我解决这个问题。希望它在FF或Chrome中有效,但只有IE。
#2
29
No, that would be a huge security breach. Imagine if someone could run
不,这将是一个巨大的安全漏洞。想象一下,如果有人可以跑
format c:
whenever you visted their website.
每当你访问他们的网站。
#3
18
It is possible when the page itself is opened via a file:///
path.
通过file:///路径打开页面本身是可能的。
<button onclick="window.open('file:///C:/Windows/notepad.exe')">
Launch notepad
</button>
However, the moment you put it on a webserver (even if you access it via http://localhost/
), you will get an error:
但是,当您将它放在Web服务器上时(即使您通过http:// localhost /访问它),您将收到错误:
Error: Access to 'file:///C:/Windows/notepad.exe' from script denied
错误:从拒绝的脚本访问'file:/// C:/Windows/notepad.exe'
#4
4
You can do it on Internet explorer with OCX component and on chrome browser using a chrome extension chrome document in any case need additional settings on the client system!
您可以使用OCX组件在Internet Explorer上执行此操作,在chrome浏览器上使用chrome扩展名chrome文档,无论如何都需要在客户端系统上进行其他设置!
Important part of chrome extension source:
chrome扩展源的重要部分:
var port = chrome.runtime.connectNative("your.app.id");
port.onMessage.addListener(onNativeMessage);
port.onDisconnect.addListener(onDisconnected);
port.postMessage("send some data to STDIO");
permission file:
{
"name": "your.app.id",
"description": "Name of your extension",
"path": "myapp.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://IDOFYOUREXTENSION_lokldaeplkmh/"
]
}
and windows registry settings:
和Windows注册表设置:
HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\your.app.id
REG_EXPAND_SZ : c:\permissionsettings.json
#5
1
You can not run/execute an .exe file that is in the users local machine or through a site. The user must first download the exe file and then run the executable file.
So there is no possible way
您无法运行/执行用户本地计算机或站点中的.exe文件。用户必须首先下载exe文件,然后运行可执行文件。所以没有办法
The following code works only when the EXE is Present in the User's Machine.
以下代码仅在用户机器中存在EXE时有效。
<a href = "C:\folder_name\program.exe">