Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I seem to be getting slightly confused by the Task Scheduler trigger settings. (I'm on Windows Server 2008 Web)

I want to create a task that will run every 5 minutes, whether a user is logged in or not, and that goes right back into it's schedule when the computer reboots.

And so, I have set it all up as required, but notice there are two options for my Trigger:

  1. Begin the task At Startup (and then use Advanced Settings to repeat every five minutes indefinitely)
  2. Begin the task At task creation/modification (and then use Advanced Settings to repeat every five minutes indefinitely)

If I choose (1), it won't run right away. I'll have to reboot, which I don't want to do.

If I choose (2), it will run right away, but won't after next reboot.

If I create triggers for both (1) and (2), it may work, but then when I ever modify the task in future, will there be two instances of it running as both triggers are fired? Or will it override the 5-minutely intervals that have began since startup? I don't want either to happen.

Any ideas?

share|improve this question

2 Answers 2

up vote 11 down vote accepted

I'd try it like this:

  1. Add a trigger: enter image description here Make sure to set the current date and 00:00:00 as the start time
  2. Make sure the task is run as soon as possible if the start was missed: enter image description here
share|improve this answer
3  
Thanks. "Run as soon as possible if the start was missed" was the key. –  Ross Mar 22 '12 at 14:18

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
share|improve this answer
    
Hullo I think this only works if Duration is infinite - ([timespan]::MaxValue) –  Michael Jul 25 at 2:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.