---
updatedAt: 2025-08-14T13:54:01.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-sight/llms.txt
---

# Check if Task in Windows Task Scheduler Has Run

```shell VB Script
'---------------------------------------------------------
' This sample enumerates through the tasks on the local computer and
' displays their name and state.
'---------------------------------------------------------
dim strerrors

' Create the TaskService object.
Set service = CreateObject("Schedule.Service") 
call service.Connect()



' Get the task folder that contains the tasks. 
Dim rootFolder
Set rootFolder = service.GetFolder("\")
 
Dim taskCollection
Set taskCollection = rootFolder.GetTasks(0)

Dim numberOfTasks
numberOfTasks = taskCollection.Count

If numberOfTasks = 0 Then 
    Wscript.Echo "No tasks are registered."
Else
    WScript.Echo "Number of tasks registered: " & numberOfTasks
    
    Dim registeredTask
    For Each registeredTask In taskCollection

if registeredTask.LastTaskResult = 0 then

wscript.echo "Task Name: " & registeredTask.Name & " is all ok"
else
wscript.echo "Task Name: " & registeredTask.Name & " has Problems"


strerrors = "1"
end if
Next
end if

if strerrors = "1" then
wscript.echo "You have problems"
WScript.Quit(1001) 

else
wscript.echo "All OK"
WScript.Quit(0) 
end if
```

```json Response Example
{"success":true}
```

# SCRIPT