Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Windows Scheduled Tasks

$
0
0

Hi,

 

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:

AutoIt         
  1. ; Generated by AutoIt Scriptomatic
  2.  
  3. $wbemFlagReturnImmediately = 0x10
  4. $wbemFlagForwardOnly = 0x20
  5. $colItems = ""
  6. $strComputer = "localhost"
  7.  
  8. $Output=""
  9. $Output = $Output & "Computer: " & $strComputer  & @CRLF
  10. $Output = $Output & "==========================================" & @CRLF
  11. $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
  12. $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ScheduledJob", "WQL", _
  13.                                           $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
  14.  
  15. If IsObj($colItems) then
  16.    For $objItem In $colItems
  17.       $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
  18.       $Output = $Output & "Command: " & $objItem.Command & @CRLF
  19.       $Output = $Output & "DaysOfMonth: " & $objItem.DaysOfMonth & @CRLF
  20.       $Output = $Output & "DaysOfWeek: " & $objItem.DaysOfWeek & @CRLF
  21.       $Output = $Output & "Description: " & $objItem.Description & @CRLF
  22.       $Output = $Output & "ElapsedTime: " & WMIDateStringToDate($objItem.ElapsedTime) & @CRLF
  23.       $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
  24.       $Output = $Output & "InteractWithDesktop: " & $objItem.InteractWithDesktop & @CRLF
  25.       $Output = $Output & "JobId: " & $objItem.JobId & @CRLF
  26.       $Output = $Output & "JobStatus: " & $objItem.JobStatus & @CRLF
  27.       $Output = $Output & "Name: " & $objItem.Name & @CRLF
  28.       $Output = $Output & "Notify: " & $objItem.Notify & @CRLF
  29.       $Output = $Output & "Owner: " & $objItem.Owner & @CRLF
  30.       $Output = $Output & "Priority: " & $objItem.Priority & @CRLF
  31.       $Output = $Output & "RunRepeatedly: " & $objItem.RunRepeatedly & @CRLF
  32.       $Output = $Output & "StartTime: " & WMIDateStringToDate($objItem.StartTime) & @CRLF
  33.       $Output = $Output & "Status: " & $objItem.Status & @CRLF
  34.       $Output = $Output & "TimeSubmitted: " & WMIDateStringToDate($objItem.TimeSubmitted) & @CRLF
  35.       $Output = $Output & "UntilTime: " & WMIDateStringToDate($objItem.UntilTime) & @CRLF
  36.       if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
  37.       $Output=""
  38.    Next
  39.    Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ScheduledJob" )
  40.  
  41.  
  42. Func WMIDateStringToDate($dtmDate)
  43.  
  44.     Return (StringMid($dtmDate, 5, 2) & "/" & _
  45.     StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
  46.     & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))

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?

 

Thanks,

 

Rob


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>