jwenjian/ghiblog

[From Instapaper] : Task Scheduler - Windows applications | Windows上的定时任务管理器

jwenjian opened this issue · 1 comments

Task Scheduler - Windows applications

05/31/2018 2 minutes to read In this article Purpose Where applicable Developer audience Run-time requirements In this section Purpose The Task Scheduler…



July 12, 2019 at 10:46PM

via Instapaper https://ift.tt/2LNIHSk

Windows上自带的任务管理器, 类似于Linux系统的crontab, 提供了一个GUI界面, 允许用户指定:

  • 触发器

触发器支持以下方式触发:
image

  • 操作

操作支持启动程序, 发送电子邮件(win10版已弃用), 显示消息(win10版已弃用)

image

当配置完以上选项之后, windows会为此任务生成一个xml文件, 存储在C:/Windows/System32/Tasks目录下, 比如下面这个xml就是windows office更新检查的定时任务:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2017-08-05T12:13:18.0043321</Date>
    <Author>Microsoft Office</Author>
    <Description>This task ensures that your Microsoft Office installation can check for updates.</Description>
    <URI>\Microsoft\Office\Office Automatic Updates 2.0</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2010-12-16T03:00:00</StartBoundary>
      <Enabled>true</Enabled>
      <RandomDelay>PT12H</RandomDelay>
      <ScheduleByWeek>
        <DaysOfWeek>
          <Sunday />
          <Monday />
          <Tuesday />
          <Wednesday />
          <Thursday />
          <Friday />
          <Saturday />
        </DaysOfWeek>
        <WeeksInterval>1</WeeksInterval>
      </ScheduleByWeek>
    </CalendarTrigger>
    <LogonTrigger>
      <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
      <Enabled>true</Enabled>
      <Delay>PT5M</Delay>
    </LogonTrigger>
    <IdleTrigger>
      <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
      <Enabled>true</Enabled>
    </IdleTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>A-0-0-000</UserId>
      <RunLevel>HighestAvailable</RunLevel>
      <LogonType>InteractiveToken</LogonType>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>true</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>false</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT30M</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe</Command>
      <Arguments>/frequentupdate SCHEDULEDTASK displaylevel=False</Arguments>
    </Exec>
  </Actions>
</Task>