从命令行使用schtasks,什么参数将把计算机从睡眠中唤醒并执行任务 [英] Using schtasks from the command line, what parameter will wake the computer from sleep and execute the task

查看:486
本文介绍了从命令行使用schtasks,什么参数将把计算机从睡眠中唤醒并执行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此选项存在于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 code> / query 。有了这个任务的XML编码,你可以看到 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:


  1. 在任务计划程序UI中,选择唤醒计算机以运行此任务 - 单击任务并将导出... 复制到XML。然后,您可以在另一台机器上重新导入此文件(请参阅下文),并且将设置待机运行。或

  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,

通过命令行创建具有基本设置(操作,时间等)的任务。然后,导出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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆