I'm trying to find a way to query the setup Windows Scheduled Tasks on a local machine. I have used scriptomatic's tool to find the WMI call as can be seen below:
; Generated by AutoIt Scriptomatic
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ScheduledJob", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
$Output = $Output & "Caption: " & $objItem.Caption & @CRLF
$Output = $Output & "Command: " & $objItem.Command & @CRLF
$Output = $Output & "DaysOfMonth: " & $objItem.DaysOfMonth & @CRLF
$Output = $Output & "DaysOfWeek: " & $objItem.DaysOfWeek & @CRLF
$Output = $Output & "Description: " & $objItem.Description & @CRLF
$Output = $Output & "ElapsedTime: " & WMIDateStringToDate
($objItem.ElapsedTime) & @CRLF
$Output = $Output & "InstallDate: " & WMIDateStringToDate
($objItem.InstallDate) & @CRLF
$Output = $Output & "InteractWithDesktop: " & $objItem.InteractWithDesktop & @CRLF
$Output = $Output & "JobId: " & $objItem.JobId & @CRLF
$Output = $Output & "JobStatus: " & $objItem.JobStatus & @CRLF
$Output = $Output & "Name: " & $objItem.Name & @CRLF
$Output = $Output & "Notify: " & $objItem.Notify & @CRLF
$Output = $Output & "Owner: " & $objItem.Owner & @CRLF
$Output = $Output & "Priority: " & $objItem.Priority & @CRLF
$Output = $Output & "RunRepeatedly: " & $objItem.RunRepeatedly & @CRLF
$Output = $Output & "StartTime: " & WMIDateStringToDate
($objItem.StartTime) & @CRLF
$Output = $Output & "Status: " & $objItem.Status & @CRLF
$Output = $Output & "TimeSubmitted: " & WMIDateStringToDate
($objItem.TimeSubmitted) & @CRLF
$Output = $Output & "UntilTime: " & WMIDateStringToDate
($objItem.UntilTime) & @CRLF
$Output=""
Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ScheduledJob" )
Func WMIDateStringToDate
($dtmDate)
When running this on any machine I appear to get nothing. Can anyone advise into how I'd use this to find out for example the statuses of the current scheduled tasks on my machine?