如何在 win 10 上调试任务调度程序?

How to debug task scheduler on win 10?

我试图在我的电脑上每 15 分钟执行一次以下 bat:

@ECHO OFF

SETLOCAL enabledelayedexpansion

SET host=http://dnsad.de/rest/
SET slideshowurl=http://dnsad.de/display/currentSlideshow/mac/
SET slideshowfolder=C:\Slideshow
SET ieprocess="iexplore.exe"
SET ignore_result=INFORMATION:

FOR /f "delims=" %%a IN ('getmac /v ^|find /i "Realtek"') DO (
    FOR %%b IN (%%a) DO (
        SET element=%%b
        IF "!element:~2,1!!element:~5,1!!element:~8,1!"=="---" set mac=%%b
    )
)

SET formattedmac=%mac:-=:%
SET macpath=%mac:-=_%

FOR /f "delims=" %%a IN ('curl -X GET %host%%formattedmac%') DO (
    FOR %%b IN (%%a) DO (
        SET update=%%b
    )
)

IF "%update%"=="[true]" (
    CD %ProgramFiles%\WinHTTrack\
    httrack %slideshowurl%%formattedmac% -q -O "C:\Slideshow" -s0 -B -a
    curl -X PUT %host%%formattedmac%

    START iexplore -k %slideshowfolder%\dnsad.de\display\currentSlideshow\mac\%macpath%.html
)

EXIT

脚本在执行时可以正常工作。我正在获取设备的 mac 地址,从 curl 获取预期的服务器响应,WinHTTrack 正在正确备份数据,curl 更新服务器字段,然后使用更新的本地 html 打开 Internet Explorer。

在 win 7 中安排为任务时,它也能正常工作。当 运行 来自 Win 10 上的任务计划程序的 bat 时,它所做的最后一件事是 curl PUT,但永远不会打开 Internet Exploerer。任务被标记为成功。

我在 Win 7 和 Win 10 上以管理员身份登录。我几乎测试了 taskscheduler 中的每个设置。似乎没有任何效果。为什么 Internet Explorer 无法启动?

[编辑]

似乎是选项 "Run whether user is logged on or not" 导致了问题。但这里有一个问题: 我在 Internet Explorer Kiosk 模式下显示幻灯片,需要从我的服务器获取更新数据以定期显示新幻灯片。提到的选项可防止在执行 bat 文件时弹出控制台。如果我 "only execute if user is logged on" 我确实让更新的数据显示在 Internet Explorer 中,但每隔 15 分钟就会弹出一个控制台 window 一秒钟。

我尝试用 cmd /c "update" /min "PATH TO BAT" 执行,但没有解决问题。

正如我在 [编辑] 中提到的,问题是选项 "run whether user is logged on or not",我用它来防止命令行 window 弹出。当我使用选项 "only execute if user is logged on" 时,我需要 "wrap" 不打开 cli 的 VBScript 中的 bat。因此,通过使用以下行安排 vbs:

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "cmd /c PATH\TO\BAT", 0, True

我可以在没有闪烁的 cli 的情况下执行 bat。