Creating Task With a Batch File - run task as soon as possible if missed

7

When creating a task with a batch file or command line, how do I specify the following option?

Run task as soon as possible after a scheduled start is missed

I know that this option exists via the GUI, but I need to specify it via command line.

Nick Painter

Posted 2013-09-27T16:46:02.330

Reputation: 467

Answers

10

There is no command line option for this. One workaround is to create the tasks with that option, using the GUI, then export it to an XML file. Then you can run it with

schtasks /create /TN "New Task" /xml "C:\TEMP\New Task.xml" /RU DOMAIN\username /RP password

Debra

Posted 2013-09-27T16:46:02.330

Reputation: 4 000

Anyone know if this is possible now after 4 years? – Robert – 2017-11-28T03:19:21.367

Thank you so much. Exactly what I was looking for. Good to know its not possible with just commandline either. – Nick Painter – 2013-09-27T18:23:26.950

1

Powershell to rescue, use -StartWhenAvailable

Set-ScheduledTask `
    -TaskName $TaskName `
    -TaskPath $TaskPath `
    -Trigger $(New-ScheduledTaskTrigger -At "01.01.2018 05:00:00" -DaysOfWeek $day -Weekly -Verbose) `
    -Settings $(New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries)

Harmandeep Saggu

Posted 2013-09-27T16:46:02.330

Reputation: 11