Creating a scheduled task in Windows that will run at intervals indefinitely
Solution 1:
I'd try it like this:
- Add a trigger: Make sure to set the current date and 00:00:00 as the start time
- Make sure the task is run as soon as possible if the start was missed:
Solution 2:
Here's how to create such scheduled task using PowerShell:
$executable = "foo.exe"
$taskName = "My Task"
$action = New-ScheduledTaskAction -execute $executable
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).Date
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable
Register-ScheduledTask -TaskName $taskName -Trigger $trigger -Action $action -Setting $settings -description $description -User "NT AUTHORITY\SYSTEM" -RunLevel 1
$trigger.RepetitionInterval = (New-TimeSpan -Minutes 5)
$trigger.RepetitionDuration = (New-TimeSpan -Days 1000)
Set-ScheduledTask $taskName -Trigger $trigger