从命令行使用schtasks,什么参数将把计算机从睡眠中唤醒并执行任务 [英] Using schtasks from the command line, what parameter will wake the computer from sleep and execute the task
问题描述
此选项存在于UI中,但不在命令行显示的帮助中。
The option exists in the UI, but not in the help displayed in the command line.
推荐答案
通过 schtasks.exe
命令行或更新现有任务执行新任务?
Are you creating a new task via the schtasks.exe
command line, or updating an existing task?
$ c> schtasks.exe 对 / create
和都有
。有了这个任务的XML编码,你可以看到 / xml
code> / query WakeToRun
节点可以设置为从睡眠唤醒计算机以运行任务:
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>
如果您需要从唤醒计算机的命令行创建任务,的任务改为XML,修改此XML以添加 WakeToRun
,然后重新导入此XML定义。您可以通过以下两种方式:
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:
-
在任务计划程序UI中,选择唤醒计算机以运行此任务 - 单击任务并将
导出...
复制到XML。然后,您可以在另一台机器上重新导入此文件(请参阅下文),并且将设置待机运行。或
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,
通过命令行创建具有基本设置(操作,时间等)的任务。然后,导出XML,以编程方式添加 WakeToRun
节点(通过XSLT或search / replace),然后重新导入此更新的XML:
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
schtasks.exe /create /tn /xml MyTask.xml /f
这篇关于从命令行使用schtasks,什么参数将把计算机从睡眠中唤醒并执行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!