You can set the starting time for tasks and set the interval at which it repeats, but that's about it for individual tasks.
If you want to create a single task that runs every 3 hours, starting at 09:00
, you could do something like this:
Schtasks /Create /TN example /TR C:\example\report.bat /SC DAILY /ST 09:00 /DU 300 /RI 180
Notice that i set /DU
: it's a requirement of schtasks.exe that the duration is more than the run interval.
If you wanted to create several tasks to run at different times, I'd either add one at a time or have them each on a single line of a file that is then passed through a batch file (which is effectively the same). Once you get into delimited lists it gets messy; I haven't found a pretty way to extract data from them yet. It's certainly possible, but feels like the kind of thing that people tell you is "bad practice".
To add several tasks in succession, I'd create a batch file that looked something like this:
set i=1
:top
set /P input=if you want to create a scheduled task, enter the time you want in HH:MM format. otherwise, type "q" :
if (%input%) EQU (q) exit /B 0
Schtasks /Create /TN %username%\%i% /TR C:\example\report.bat /SC DAILY /ST %input% /RU %username%
set /A i+=1
goto top
The tasks created are numbers starting at one and counting up to infinity (as far as the user goes) and filed under a folder titled the same as the username of the person who ran the script. Technically, the name you access them by would be "%username%\1", "%username%\2". This is so that multiple users can use the same script to make multiple tasks without the danger of overwriting each others tasks.
The script can be stopped at any time by entering "q" by itself.
Potentially, you could input a file to this script with one time on each line and a q at the end, and it would run through the entire list and exit.