0

I need to get the list of scheduled tasks that are present in the local computer.

How can I achieve that using c# for Windows XP?

aF.
  • 64,980
  • 43
  • 135
  • 198
  • see this: http://stackoverflow.com/questions/6477693/c-sharp-how-to-list-scheduled-tasks-for-a-specific-user-with-the-taskschedular – nawfal Apr 05 '12 at 10:19
  • @ErikLarsson I've tried what nawfal said but I'm missing some import and `ScheduledTask` class is not resolved. – aF. Apr 05 '12 at 10:22
  • @aF. I´m afraid that if you dont shows us some code that we wont be able to help. – Erik Larsson Apr 05 '12 at 10:26
  • @Af.: it is so obvious - search google for `"ScheduledTasks class MSDN"` – sll Apr 05 '12 at 10:26
  • it depends on framework in fact. Do you have .net 4? – nawfal Apr 05 '12 at 10:27
  • 1
    @sll it gives me this: http://msdn.microsoft.com/en-us/library/microsoft.office.excel.server.addins.computecluster.taskscheduler.scheduledtasks%28v=office.12%29.aspx Do you really think it's the excel that provides this? :) – aF. Apr 05 '12 at 10:27
  • @nawfal yes I've .net Framework 4.0 – aF. Apr 05 '12 at 10:28
  • try this link: http://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.getscheduledtasks.aspx isnt it talking about a namespace we know? Try this link for a library: http://taskscheduler.codeplex.com/ – nawfal Apr 05 '12 at 10:33
  • As suggested by OP: try this [link](http://msdn.microsoft.com/en-us/library/system.threading.tasks.taskscheduler.getscheduledtasks.aspx). Isnt it talking about a namespace we know? Or even better: [try managed wrapper from codeplex](http://taskscheduler.codeplex.com) (which wraps the COM interface) – nawfal Apr 05 '12 at 10:37

1 Answers1

6

1 alternative...:

1) you can read from the folder where task are saved ( Ive just tested it - win7)

c:\Windows\System32\Tasks\

this is simple xml file like this :

<?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>
Royi Namir
  • 144,742
  • 138
  • 468
  • 792