【问题标题】:schtasks /create (Have a task that runs every day and repeats every hourschtasks /create(有一个每天运行并每小时重复的任务
【发布时间】:2014-02-21 15:38:42
【问题描述】:

很抱歉,如果有人问过这个或类似的问题,我希望我错过了一些愚蠢的东西,这很容易,但是。如何使用 schtasks /create 命令创建一个任务,该命令将在每天 7 点开始,并无限期地或在一天内每小时重复一次?

如果我这样做

schtasks /create /tn "test" /tr "\"C:\Program Files\test.exe"" /sc HOURLY /mo 1

只有在指定的日期和时间被命中时才会触发。

如果我这样做

schtasks /create /tn "test" /tr "\"C:\Program Files\test.exe"" /sc DAILY /mo 1

每天只会触发一次。

提前致谢!

【问题讨论】:

  • 批处理文件本身可以使用 timeout 延迟 60 分钟,然后再次循环开始。计划任务可以在早上 7 点启动批处理文件。
  • 嗯,这可能是一种 hacky 方式,但如果计算机在 7 点未打开或在 7 点后关闭,它将无法启动批处理文件或重新启动批处理文件.

标签: batch-file scheduled-tasks windows-task-scheduler


【解决方案1】:

想通了,重复间隔基本上是我所需要的以及持续时间

以下是如何安排每天 7:00 每隔 1 小时运行一次,持续 1 天。

schtasks /create /tn "test" /tr "\"test.exe"" /sc DAILY /st 07:00 /f /RI 60 /du 24:00

【讨论】:

    【解决方案2】:

    Windows 8.1 的帮助中有这个例子。还有一个HOURLY 开关。

    ==> Creates a scheduled task "accountant" on the remote machine
        "ABC" to run calc.exe every five minutes from the specified
        start time to end time between the start date and end date.
    
        SCHTASKS /Create /S ABC /U domain\user /P password /SC MINUTE
                 /MO 5 /TN accountant /TR calc.exe /ST 12:00 /ET 14:00
                 /SD 06/06/2006 /ED 06/06/2006 /RU runasuser /RP userpassword
    

    【讨论】:

    • ooo 我想我明白了……但是,我该如何做到这一点? (不只是在开始和结束日期之间)
    猜你喜欢
    • 1970-01-01
    • 2022-01-03
    • 2010-10-05
    • 2019-11-25
    • 2021-11-27
    • 2012-01-26
    • 2021-04-05
    • 2020-10-23
    • 1970-01-01
    相关资源
    最近更新 更多