WScript从客户端PC运行exe而没有任何弹出窗口,默默无闻

时间:2015-09-28 09:37:28

标签: html asp.net internet-explorer hta wsh

我的目标是从客户端PC启动 .exe ,从 Internet Explorer ,无需任何用户交互。我正在沙箱环境中部署,因此我不关心安全性。

我尝试使用 .hta 文件来运行exe,代码如下:

function RunExe(){
    var shell = new ActiveXObject("WScript.Shell");
    var path = "C:/Windows/System32/notepad.exe"
    shell.run(path,2,false);
    window.close();
}

记事本已成功启动,但需要额外的用户交互 - 用户需要点击“打开”才能启动它

enter image description here

我知道这听起来很有趣但我们的用户无法接受。

用户希望程序在点击链接后以静默方式执行。

有没有摆脱这个弹出框或任何解决方法?

谢谢:)

1 个答案:

答案 0 :(得分:1)

在HTA中,这对我有用:

<html>
<script>
function RunExe(){
    var shell = new ActiveXObject("WScript.Shell");
    var path = "C:/Windows/System32/Notepad.exe";
    shell.run(path,2,false);
    window.close();
}
</script>

<input style="width: 170px; height:23px; color: white; background-color: #203040; 
font-family:Book Antiqua;" type="button" Value="RunExe" onClick="RunExe();"
</html>