The option exists in the UI, but not in the help displayed in the command line.
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
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With