The option exists in the UI, but not in the help displayed in the command line.
-
Which version of windows/schtasks api do you have? – Paxenos Jan 31 '09 at 01:32
-
1All of this should now be able to be replaced by the windows scheduled task cmd-lets in powershell. Specifically the New-ScheduledTaskSettingsSet cmd-let should allow us to specify the WakeToRun setting. – thetreat May 09 '13 at 21:59
-
Actually this can be done with a powershell cmdlet (sequence) now: https://superuser.com/questions/1632277/what-is-the-command-line-equivalent-for-toggling-wake-the-computer-to-run-this/ – Fizz Mar 10 '21 at 15:10
2 Answers
Are you creating a new task via the schtasks.exe
command line, or updating an existing task?
On Vista, schtasks.exe
has an /xml
option for both /create
and /query
. With this XML encoding of the task, you can see the WakeToRun
node can be set for waking the computer from sleep to run the task:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
...
</RegistrationInfo>
<Triggers />
<Principals>
...
</Principals>
<Settings>
...
<WakeToRun>true</WakeToRun>
...
</Settings>
<Actions Context="Author">
<Exec>
<Command>myprogram.exe</Command>
</Exec>
</Actions>
</Task>
If you need to create a task from the command line that wakes the computer, you could export the basics of the task to XML, modify this XML to add WakeToRun
, then re-import this XML definition. You can do this two ways:
In the Task Scheduler UI, select "Wake the computer to run this task", right-click on the task and
Export...
to XML. You can then re-import this file on another machine (see below), and Wake-To-Run will be set. or,Via the command line, create a task with the basics set (action, time, etc). Then, export the XML, programatically add the
WakeToRun
node (via XSLT or search/replace), then re-import this updated XML:schtasks.exe /create /tn /xml MyTask.xml /f

- 4,070
- 1
- 25
- 18
-
Win 10 built-in tasks like `\Microsoft\Windows\UpdateOrchestrator\Reboot_AC` can only be updated from under the SYSTEM account, so use `psexec.exe -i -s schtasks ...` – rustyx Jul 18 '19 at 10:15
In step 2 the command line; schtasks.exe /create /tn /xml MyTask.xml /f
This may kick an error that says;
Invalid syntax. Mandatory option 'tn' is missing.
/tn
needs a name. This should be
schtasks.exe /create /tn MyTask /xml "C:\MyTask.xml" /f
And if you have or want a space in the name, you can use;
schtasks.exe /create /tn "My Task With Spaces" /xml "C:\My Task With Spaces.xml" /f
Hope this helps...

- 23,820
- 7
- 55
- 89

- 81
- 1
- 1