【问题标题】:How to get the list of scheduled tasks using c#?如何使用 c# 获取计划任务列表?
【发布时间】:2012-04-19 01:57:19
【问题描述】:

我需要获取本地计算机中存在的计划任务列表。

如何在 Windows XP 上使用 c# 来实现这一点?

【问题讨论】:

  • @ErikLarsson 我已经尝试了 nawfal 所说的,但我缺少一些导入并且 ScheduledTask 类未解决。
  • @aF。恐怕如果您不向我们展示一些我们将无法提供帮助的代码。
  • @Af.:这很明显 - 在谷歌上搜索 "ScheduledTasks class MSDN"
  • @sll 它给了我这个:msdn.microsoft.com/en-us/library/… 你真的认为是 excel 提供了这个吗? :)

标签: c# scheduled-tasks


【解决方案1】:

1 个替代方案...:

1)您可以从保存任务的文件夹中读取(我刚刚测试过 - win7)

c:\Windows\System32\Tasks\

这是一个简单的xml文件:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2012-04-05T13:28:54.2106589</Date>
    <Author>DAVIDDOM\RoyiN</Author>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <StartBoundary>2012-04-05T13:28:43.2046589</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByDay>
        <DaysInterval>1</DaysInterval>
      </ScheduleByDay>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <RunLevel>LeastPrivilege</RunLevel>
      <UserId>DAVIDDOM\RoyiN</UserId>
      <LogonType>InteractiveToken</LogonType>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT1H</WaitTimeout>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Windows\system32\charmap.exe</Command>
    </Exec>
  </Actions>
</Task>

【讨论】:

  • 这是可能的,但 nawfal 的答案是要走的路:)
猜你喜欢
  • 2011-07-26
  • 1970-01-01
  • 2019-03-26
  • 2014-05-22
  • 2017-05-12
  • 2011-10-06
  • 2021-06-15
  • 2012-04-25
  • 1970-01-01
相关资源
最近更新 更多