【问题标题】:Windows task scheduler - Non-repeating only run during window of timeWindows 任务计划程序 - 非重复仅在时间窗口内运行
【发布时间】:2020-08-07 16:12:40
【问题描述】:

我设置了一个由工作站解锁触发的非重复任务。我怎样才能调节它以便只在一天中的特定时间段内运行?例如上午 8 点到 10 点之间?

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

【问题讨论】:

    标签: windows scheduled-tasks


    【解决方案1】:

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

    您需要使用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
    

    像魅力一样工作。现在,每次我回到笔记本电脑并登录时,这些文件都不会打开。

    【讨论】:

      猜你喜欢
      • 2011-05-22
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-22
      相关资源
      最近更新 更多