【问题标题】:Run .exe file from the browser in non-IE browsers like chrome and firefox在非 IE 浏览器(如 chrome 和 firefox)中从浏览器运行 .exe 文件
【发布时间】:2015-05-01 11:34:55
【问题描述】:

我试图仅在本地通过 HTML 启动 putty.exe 文件。我制作了一个包含环境列表的 HTML 页面,当您单击特定环境时,它会在 putty 中打开会话。我能够通过一个 ActiveX 对象来实现这一点,但它只适用于 IE。我正在尝试使其跨浏览器兼容,以便它也可以在 Chrome 或 Firefox 上运行。我的 HTML 页面如下所示:

<html>
<head>
    <script>
        function LaunchApp(envName) {
            var env = envName
            var oshell = new ActiveXObject("WScript.Shell");
            var commandtoRun = "C:\\putty.exe "+env;
            oshell.Exec(commandtoRun);
        }
    </script>
</head>
<body>
    <h1>Run a Program</h1> 
    This script launch the file any Exe File<p> 
    <!--
        <button onclick="LaunchApp('gsamqaauth.sapient.com')">Run Exe File</button>  
    -->
    <a href="#" onclick="LaunchApp('enviornment')">environment</a>
</body>
</html>

【问题讨论】:

  • Edit 更改了标题以适应问题,而不是建议的方法。
  • 出于安全原因,我很确定在大多数较新的浏览器中已禁用此功能。这永远不会发生或由网络浏览器工程师启用。你在 IE 7 下运行的是什么 IE?大声笑

标签: javascript html google-chrome firefox activex


【解决方案1】:

在 Windows 上,您可以使用 custom URL protocols 从浏览器启动可执行文件。 Chrome 和 Firefox 以及 Internet Explorer 都支持这一点。

【讨论】:

    猜你喜欢
    • 2019-02-03
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-08
    相关资源
    最近更新 更多