HTML:如何从HTML网页执行setup.exe进程

问题描述 投票:0回答:1

我在网络驱动器上有一堆应用程序,我希望允许用户单击按钮即可执行。我已经研究了该主题,但是在尝试构建网页时出现错误。我的老板要求我通过网页而不是通过Web应用程序来执行此操作。甚至无法确定是否可以将其作为ASP Web应用程序执行。

代码:

<!DOCTYPE html>
<html>
<body>
<h1>Test App</h1>
<input id="clickMe" type="button" value="clickme" onclick="RunFile();" />
<script type="text/javascript" language="javascript">

    function RunFile() {
    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
    }
</script>
</body>
</html>

到目前为止,这是我的文件夹中的内容:enter image description here

我在测试时发现IE错误。我认为这段代码只能在IE中使用。我在这里的某处阅读,您只能使用IE来执行此操作。我想通过chrome来执行此操作,但我不知道您是否可以通过Chrome来运行exe。无论如何,这是错误:

SCRIPT429: Automation server can't create object

我认为我缺少一些文件或某些东西才能正常工作。老实说,我宁愿将其构建为Web应用程序,但在老板批准之前,我必须首先将其构建为html网页。

javascript html internet-explorer activex
1个回答
0
投票

出于安全原因,您无法从浏览器窗口运行应用程序。要执行文件,您需要使用.HTA应用程序(这是HTML应用程序)。 HTA应用程序像普通应用程序一样在浏览器窗口外运行,并具有完全的信任支持。

示例代码:

<html>
<head>
    <title>Application Executer</title>
    <HTA:APPLICATION ID="oMyApp" 

        APPLICATIONNAME="Application Executer" 

        BORDER="no"

        CAPTION="no"

        SHOWINTASKBAR="yes"

        SINGLEINSTANCE="yes"

        SYSMENU="yes"

        SCROLL="no"

        WINDOWSTATE="normal">
    <script type="text/javascript" language="javascript">
        function RunFile() {
        WshShell = new ActiveXObject("WScript.Shell");
        WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
        }
    </script>
</head>
<body>
    <input type="button" value="Run Notepad" onclick="RunFile();"/>
</body>
</html>

输出:

enter image description here

参考:

How to execute a Local File using HTML Application?

© www.soinside.com 2019 - 2024. All rights reserved.