任务计划程序未运行HTA文件

问题描述

任务计划程序似乎没有运行HTA文件我有这样的动作:

操作:“启动应用程序”
程序/脚本路径:C:/TestMeeting.hta
开始于:C:/

因此它应该运行HTA,但是当任务被触发时,它什么也不做。它说它的状态正在运行。它永远不会停止,我必须手动停止它。我尝试过的另一件事是使用“ C:\ Windows \ SysWOW64 \ mshta.exe”作为程序路径,然后将HTA路径放入“添加参数”框中。它运行并说成功完成了,但是什么也没发生。

那我该如何使用Task Scheduler运行HTA文件

以下是HTA中的代码(如果需要的话):

<Script Language=JavaScript>
    var window = open("https://ww2.livelesson.com/REMOVED_FOR_Security_REASONS");
    function SignIn() {
    setTimeout(function(){
    try{
    var corral = window.document.getElementsByClassName("loginField coral3-Tab")[0];
    corral.click();
    var text = window.document.getElementsByClassName("coral-Textfield login-textfield coral3-Textfield coral3-Textfield--quiet")[0];
    text.value = "Name";
    var button = window.document.getElementsByClassName("coral3-Button coral3-Button--cta enterRoom")[0];
    button.click();
    closeEveyThing();
    } catch (error) {
    SignIn();
    }
    },500);
    }
    function closeEveyThing() {
    setTimeout(function(){
    window.close();
    close();
    },10000);
    }
    SignIn();
    </Script>

更新: 我发现您可以运行带有HTA路径的mshta.exe作为bash中的参数:

cd
/mnt/c/Windows/System32/mshta.exe C:/TestMeeting.hta

它运行良好,所以在参数中使用C:/TestMetting.hta运行C:/Windows/System32mshta.exe似乎很奇怪。

解决方法

我仍然不知道为什么不运行HTA文件,但是它可以运行.bat文件。 如果将以下代码放在.bat文件中,然后运行.bat文件,它将起作用。

cd
mshta.exe C:/PATH_TO_HTA/Example.hta