hta / javascript如何执行具有相对路径的应用程序

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

我正在构建一个.hta(使用javascript),我想从中启动几个应用程序。

但是当我执行.hta时,出现错误消息找不到文件

这是代码:

<script type="text/javascript" language="javascript">
    function RunFile(path) {
    var relpath = window.location.href;
    var fullpath = relpath + path;

    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run(fullpath, 1, false);
    }

    RunFile("\file.exe");
</script>
javascript html wsh hta
1个回答
4
投票

window.location.href也包括文件名和协议。试试这个:

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