views:

2055

answers:

3

The option exists in the UI, but not in the help displayed in the command line.

+1  A: 

It can't be done; this post may help get you started though....

Patrick Cuff
+2  A: 

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"&gt;
  <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:

  1. 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,

  2. 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

NicJ
A: 

can u use schtasks to import xml scheduler and specify its location in the TaskScheduler Library?

for instace: Task Scheduler Library ->Microsoft -->Windows --->MySchedulers

i tried setting the <'URI'> tag in the xml under Task->RegistrationInfo, like this: <'URI'>'Microsoft\Windows\MySchedulers<'/URI'>, but it didn't work. it always create the scheduler under the root level.

any ideas??