WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Task Scheduler

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List Scheduled Tasks

 Keywords: List Enum Enumerate Scheduled Tasks Vista

VISTA OR NEWER REQUIRED

Reference: http://msdn.microsoft.com/en-us/library/aa383614(VS.85).aspx

#DefineFunction Get_Tasks()
   oService = CreateObject("Schedule.Service")
   oService.Connect()
   orootFolder = oService.GetFolder("\")
   otcol = orootFolder.GetTasks(0)
   tcnt = otcol.Count
   task_list = ""
   If tcnt == 0 Then
       Message("HI","No tasks are registered.")
   Else
       ForEach itask In otcol
         Switch(itask.State)
           Case 0
               taskState = "Unknown"
               Break
           Case 1
               taskState = "Disabled"
               Break
           Case 2
               taskState = "Queued"
               Break
           Case 3
               taskState = "Ready"
               Break
           Case 4
               taskState = "Running"
               Break
         EndSwitch
         task_list =  task_list:StrFix(taskState," ",10):" - ":itask.Name:@TAB
       Next
   EndIf
   task_list = StrTrim(task_list)
   otcol = 0
   orootFolder = 0
   oService = 0
   Return task_list
#EndFunction

task_list = Get_Tasks()
AskItemlist("Task List",task_list, @TAB, @UNSORTED, @SINGLE )
Exit

Article ID:   W18202
Filename:   List Scheduled Tasks.txt
File Created: 2014:05:02:09:38:46
Last Updated: 2014:05:02:09:38:46