Windows 任务调度程序 - 在 window 时间内仅 运行 不重复

Windows task scheduler - Non-repeating only run during window of time

我设置了一个由工作站解锁触发的非重复任务。我如何调整它以便仅在白天的特定时间段内运行?例如 8-10 A.M?

之前有一个 similar question 回答,但该解决方案只能用于重复任务。

我希望得到一个答案,回来后什么也没有,但因为我非常需要一个答案,所以我自己找到了。这个过程总是让我惊讶。

您需要使用 IF 命令通过批处理文件完成您的任务。这是代码:

@ECHO OFF
:: For using just the hour digit of 'time' variable
SET hour=%time:~0,2%

:: Let's say I want whatever it is to run only when I'm unlocking the station between 8-10 A.M.
IF %hour% GEQ 8 IF %hour% LEQ 10 (GOTO RUNIT)

GOTO END

:RUNIT
:: Put your commands here, I want to open a bunch of text files I'm working on.
start notepad "D:\file1.txt"
start notepad "D:\file2.txt"

:END

很有魅力。现在,每次我回到我的笔记本电脑并登录时,这些文件都不会打开。