8

Sorry if this or similar has been asked, and I hope I'm missing something stupid and this is easy, but. How do I make a task using the schtasks /create command that will start say every day at 7 and repeat every hour either indefinitely or for the duration of a day?

If I do

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

it will only trigger if the specified date and time are hit.

If I do

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

it will only trigger once a day.

Thanks in advance!

Andriy M
  • 76,112
  • 17
  • 94
  • 154
Ivan S
  • 1,051
  • 6
  • 14
  • 26
  • The batch file itself can delay for 60 minutes using `timeout` and loop to the start again. The scheduled task can launch the batch file at 7am. – foxidrive Jan 30 '14 at 11:47
  • Hmm that could be a hacky way to do it, but if the computer isn't turned on at 7 or is turned off after seven, it would fail to launch the batch file or relaunch the batch file. – Ivan S Jan 30 '14 at 13:25

2 Answers2

15

Figured it out, Repeat Interval is essentially what I needed along with duration

Below is how to schedule something to run at 7:00 every day every 1 hour for a duration of 1 day.

schtasks /create /tn "test" /tr "\"test.exe"" /sc DAILY /st 07:00 /f /RI 60 /du 24:00
Ivan S
  • 1,051
  • 6
  • 14
  • 26
3

Windows 8.1 has this example in the help. There is an HOURLY switch too.

==> 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
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • ooo I think I see... however, how would I make it so it's every day? (not just between the start and end date) – Ivan S Jan 30 '14 at 18:20