#include-once #include ; remarks: ; script will only function with Vista or higher version ; include taskplanerCOM.au3 to verify compatibility with OS version ; and un-remark below two lines if needed ;~ #include ;~ If Not _TaskIsValidPlatfrom() Then Exit MsgBox(48, "Error", "Task Scheduler 2.0: Client requires Windows Vista. Server requires Windows Server 2008") ;~ Opt("MustDeclareVars", 1) ; #Functions# =================================================================================================================== ;_TaskGetFolders ;_TaskListAllDetailed ;_TaskListToText ; =============================================================================================================================== Global $aTaskList, $aFolders ; show all Task Scheduler Library folders _TaskGetFolders($aFolders) _ArrayDisplay($aFolders, "Task Scheduler Library folders") ; Get All Scheduled Tasks defined in Root of Task Scheduler Library $aTaskList = _TaskListAllDetailed() If @error Then ConsoleWrite(@ScriptLineNumber & " error: " & @error & " " & @extended & @CR) ; formatted output to Scheduled tasks.txt _TaskListToText($aTaskList) If @error Then ConsoleWrite(@ScriptLineNumber & " error: " & @error & @CR) Else Run("notepad.exe Scheduled tasks.txt"); , "", @SW_SHOWMAXIMIZED) EndIf _ArrayDisplay($aTaskList, "Scheduled Tasks in Root of Task Scheduler Library") ; Get All scheduled tasks as defined on this system $aTaskList = _TaskListAllDetailed("\", 1, True) _ArrayDisplay($aTaskList, "All scheduled tasks as defined on this system") ; Get All Scheduled Tasks defined in \Microsoft\Windows Defender $aTaskList = _TaskListAllDetailed("\Microsoft\Windows Defender") _ArrayDisplay($aTaskList, "Scheduled tasks Windows Defender") Exit ; #FUNCTION# ==================================================================================================== ; Function ......: _TaskListAllDetailed([$sFolder = "\"[, $bHidden = 1[, $bRecurse = False]]]) ; Description ...: returns a detailed array of all tasks in a given taskfolder, recursively ; Parameters ....: $sFolder - Optional: Path to scheduled Tasks (default = "\") ; $bHidden - Optional: 0 to retrieve all the tasks in the folder excluding the hidden tasks (default = 1) ; $bRecurse - Optional: Recurse all folders as from $sFolder path (default = False) ; Return values .: Success - Returns Array of scheduled tasks ; Failure - Returns 0 and sets @error: ; |1 - $oService is not an object ; |2 - $oFolder is not an object ($sFolder folder does not exist) ; |3 - $oTasks is not an object ; |4 - $bRecurse is not boolean ; |5 - $bHidden is not an integer ; |6 - Recursive only: TaskGetFolders() returned an error. Please check @extended for more information ; Authors........: GreenCan ; Complement to..: allow2010 UDF ; Remarks .......: Compatible with Win7 and above ; Link ..........: http://www.autoitscript.com/forum/topic/135994-taskplanner-udf/ ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382542%28v=vs.85%29.aspx ; Example .......: Yes ; =============================================================================================================== Func _TaskListAllDetailed($sFolder = "\", $bHidden = 1, $bRecurse = False) If Not IsBool($bRecurse) Then Return SetError(4, 0, 0) If Not IsInt($bHidden) Then Return SetError(5, 0, 0) Local $iCount = 1 Local $oService, $oFolder, $oTasks, $oTaskDefinition, $oActions, $aAttachments, $sAttachments, $oPrincipal, _ $oRegistrationInfo, $oTaskSettings, $oIdleSettings, $oTaskNetworkSettings, $colTaskTriggers, $oTaskRepetition, _ $aFolders If $bRecurse Then _TaskGetFolders($aFolders, $sFolder) If @error Then Return SetError(6, @error, 0) Else Dim $aFolders[2] $aFolders[0] = 1 $aFolders[1] = $sFolder EndIf $oService = ObjCreate("Schedule.Service") If Not IsObj($oService) Then Return SetError(1, 0, 0) $oService.Connect() Local $iColumns = 87, $iRows = 0 Local $aResult[1][$iColumns] = [[$iRows, "Enabled", "LastRunTime", "LastTaskResult", "NextRunTime", "NumberOfMissedRuns", "Path", "State", _ "Data", "ActionId", "Type", "Arguments", "Path", "WorkingDirectory", "ClassId", "Data", "e-mailFrom", "ReplyTo", "To", "CC", "BCC", "Subject", _ "Body", "Server", "Attachments", "MsgBoxTitle", "MessageBody", _ "PrincipalId", "DisplayName", "GroupId", "LogonType", "RunLevel", "UserId", _ "Author", "Date", "Description", "Documentation", "SecurityDescriptor", "Source", "URI", "Version", _ "AllowDemandStart", "AllowHardTerminate", "Compatibility", "DeleteExpiredTaskAfter", "DisallowStartIfOnBatteries", "Enabled", "ExecutionTimeLimit", "Hidden", _ "MultipleInstances", "Priority", "RestartCount", "RestartInterval", "RunOnlyIfIdle", "RunOnlyIfNetworkAvailable", "StartWhenAvailable", "StopIfGoingOnBatteries", "WakeToRun", _ "IdleSettings", "IdleDuration", "RestartOnIdle", "StopOnIdleEnd", "WaitTimeout", _ "NetworkID", "Name", _ "TriggerEnabled", "TriggerId", "StartBoundary", "EndBoundary", "ExecutionTimeLimit", "Type", _ "Delay", "Subscription", "DaysInterval", "WeeksInterval", "DaysOfWeek", "DaysOfMonth", _ "MonthsOfYear", "RandomDelay", "RunOnLastDayOfMonth", "WeeksOfMonth", "UserId", "StateChange", _ "Duration", "Interval", "StopAtDurationEnd" ]] For $__i = 1 to $aFolders[0] ;ConsoleWrite($aFolders[$__i] & @CRLF) $oFolder = $oService.GetFolder($aFolders[$__i]) If Not IsObj($oFolder) Then Return SetError(2, 0, 0) $oTasks = $oFolder.GetTasks($bHidden) If Not IsObj($oTasks) Then Return SetError(3, 0, 0) For $oItem In $oTasks ReDim $aResult[$aResult[0][0] + 2][$iColumns] $iRows += 1 $aResult[0][0] = $iRows With $oItem ; RegisteredTask object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382079%28v=vs.85%29.aspx $aResult[$iRows][0] = .Name $aResult[$iRows][1] = .Enabled $aResult[$iRows][2] = StringLeft(.LastRunTime, 4) & "/" & StringMid(.LastRunTime, 5, 2) & "/" & StringMid(.LastRunTime, 7, 2) & " " _ & StringMid(.LastRunTime, 9, 2) & ":" & StringMid(.LastRunTime, 11, 2) & ":" & StringMid(.LastRunTime, 13, 2) $aResult[$iRows][3] = .LastTaskResult $aResult[$iRows][4] = StringLeft(.NextRunTime, 4) & "/" & StringMid(.NextRunTime, 5, 2) & "/" & StringMid(.NextRunTime, 7, 2) & " " _ & StringMid(.NextRunTime, 9, 2) & ":" & StringMid(.NextRunTime, 11, 2) & ":" & StringMid(.NextRunTime, 13, 2) $aResult[$iRows][5] = .NumberOfMissedRuns $aResult[$iRows][6] = .Path $aResult[$iRows][7] = .State & "-" & ( .State = 0 ? "Unknown" : _ ( .State = 1 ? "Disabled" : _ ( .State = 2 ? "Queued" : _ ( .State = 3 ? "Ready" : _ "Running" ) ) ) ) $oTaskDefinition = .Definition $aResult[$iRows][8] = $oTaskDefinition.Data ; Action object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa446803%28v=vs.85%29.aspx $oActions = $oTaskDefinition.Actions For $oTaskAction in $oActions $aResult[$iRows][9] = $oTaskAction.Id $aResult[$iRows][10] = $oTaskAction.Type & "-" & ( $oTaskAction.Type = "0" ? "Start a program" : _ ( $oTaskAction.Type = 5 ? "Handler" : _ ( $oTaskAction.Type = 6 ? "Send an e-mail" : _ "Display a message" ) ) ) ; ExecAction object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa446890%28v=vs.85%29.aspx $aResult[$iRows][11] = ( $oTaskAction.Arguments = "0" ? "" : $oTaskAction.Arguments ) $aResult[$iRows][12] = $oTaskAction.Path $aResult[$iRows][13] = ( $oTaskAction.WorkingDirectory = "0" ? "" : $oTaskAction.WorkingDirectory ) ; ComHandlerAction object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa446820(v=vs.85).aspx $aResult[$iRows][14] = $oTaskAction.ClassId $aResult[$iRows][15] = $oTaskAction.Data ; EmailAction object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa446868%28v=vs.85%29.aspx $aResult[$iRows][16] = $oTaskAction.From $aResult[$iRows][17] = ( $oTaskAction.ReplyTo = "0" ? "" : $oTaskAction.ReplyTo ) $aResult[$iRows][18] = $oTaskAction.To $aResult[$iRows][19] = ( $oTaskAction.Cc = "0" ? "" : $oTaskAction.Cc ) $aResult[$iRows][20] = ( $oTaskAction.Bcc = "0" ? "" : $oTaskAction.Bcc ) $aResult[$iRows][21] = $oTaskAction.Subject $aResult[$iRows][22] = $oTaskAction.Body $aResult[$iRows][23] = $oTaskAction.Server $aAttachments = $oTaskAction.Attachments $sAttachments = "" For $__j = 0 to UBound($aAttachments)-1 $sAttachments &= $aAttachments[$__j] & "," Next $aResult[$iRows][24] = StringTrimRight($sAttachments, 1) ; ShowMessageAction object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382149%28v=vs.85%29.aspx $aResult[$iRows][25] = $oTaskAction.Title $aResult[$iRows][26] = $oTaskAction.MessageBody Next ; Principal object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382071%28v=vs.85%29.aspx $oPrincipal = $oTaskDefinition.Principal $aResult[$iRows][27] = $oPrincipal.Id $aResult[$iRows][28] = ( $oPrincipal.DisplayName = "0" ? "" : $oPrincipal.DisplayName ) $aResult[$iRows][29] = ( $oPrincipal.GroupId = "0" ? "" : $oPrincipal.GroupId ) $aResult[$iRows][30] = $oPrincipal.LogonType & "-" & ( $oPrincipal.LogonType = 0 ? "None" : _ ( $oPrincipal.LogonType = 1 ? "Password" : _ ( $oPrincipal.LogonType = 2 ? "Service 4 Users" : _ ( $oPrincipal.LogonType = 3 ? "Interactive (User Must be logged in)" : _ ( $oPrincipal.LogonType = 4 ? "Group" : _ ( $oPrincipal.LogonType = 5 ? "Local Service/System or Network Service" : _ "Interactive Token then Try Password" ) ) ) ) ) ) $aResult[$iRows][31] = $oPrincipal.RunLevel & "-" & ( $oPrincipal.RunLevel = 0 ? "Least Privileges (LUA)" : "Highest Privileges" ) $aResult[$iRows][32] = ( $oPrincipal.UserId = "0" ? "" : $oPrincipal.UserId ) ; RegistrationInfo object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382100%28v=vs.85%29.aspx $oRegistrationInfo = $oTaskDefinition.RegistrationInfo $aResult[$iRows][33] = $oRegistrationInfo.Author $aResult[$iRows][34] = ( $oRegistrationInfo.Date = "0" ? "" : $oRegistrationInfo.Date ) $aResult[$iRows][35] = ( $oRegistrationInfo.Description = "0" ? "" : $oRegistrationInfo.Description ) $aResult[$iRows][36] = ( $oRegistrationInfo.Documentation = "0" ? "" : $oRegistrationInfo.Documentation ) $aResult[$iRows][37] = ( $oRegistrationInfo.SecurityDescriptor = "0" ? "" : $oRegistrationInfo.SecurityDescriptor ) $aResult[$iRows][38] = ( $oRegistrationInfo.Source = "0" ? "" : $oRegistrationInfo.Source ) $aResult[$iRows][39] = ( $oRegistrationInfo.URI = "0" ? "" : $oRegistrationInfo.URI ) $aResult[$iRows][40] = ( $oRegistrationInfo.Version = "0" ? "" : $oRegistrationInfo.Version ) ; TaskSettings object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa383480%28v=vs.85%29.aspx $oTaskSettings = $oTaskDefinition.Settings $aResult[$iRows][41] = $oTaskSettings.AllowDemandStart $aResult[$iRows][42] = $oTaskSettings.AllowHardTerminate $aResult[$iRows][43] = $oTaskSettings.Compatibility & "-" & ( $oTaskSettings.Compatibility = 0 ? "configured for AT command" : _ ( $oTaskSettings.Compatibility = 1 ? "configured for Task Scheduler 1.0" : _ ( $oTaskSettings.Compatibility = 2 ? "configured for Task Scheduler 2.0 (Windows Vista / Windows 2008" : _ "configured for Task Scheduler 2.0 (Windows 7 / Windows 2008 R2" ) ) ) $aResult[$iRows][44] = $oTaskSettings.DeleteExpiredTaskAfter $aResult[$iRows][45] = $oTaskSettings.DisallowStartIfOnBatteries $aResult[$iRows][46] = $oTaskSettings.Enabled $aResult[$iRows][47] = $oTaskSettings.ExecutionTimeLimit $aResult[$iRows][48] = $oTaskSettings.Hidden $aResult[$iRows][49] = $oTaskSettings.MultipleInstances & "-" & ( $oTaskSettings.MultipleInstances = 0 ? "Run in Parallel" : _ ( $oTaskSettings.MultipleInstances = 1 ? "Add to Queue" : _ "Ignore New" ) ) $aResult[$iRows][50] = $oTaskSettings.Priority $aResult[$iRows][51] = $oTaskSettings.RestartCount $aResult[$iRows][52] = $oTaskSettings.RestartInterval $aResult[$iRows][53] = $oTaskSettings.RunOnlyIfIdle $aResult[$iRows][54] = $oTaskSettings.RunOnlyIfNetworkAvailable $aResult[$iRows][55] = $oTaskSettings.StartWhenAvailable $aResult[$iRows][56] = $oTaskSettings.StopIfGoingOnBatteries $aResult[$iRows][57] = $oTaskSettings.WakeToRun $aResult[$iRows][58] = $oTaskSettings.IdleSettings ; IdleSettings object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa380669%28v=vs.85%29.aspx $oIdleSettings = $oTaskSettings.IdleSettings $aResult[$iRows][59] = $oIdleSettings.IdleDuration $aResult[$iRows][60] = $oIdleSettings.RestartOnIdle $aResult[$iRows][61] = $oIdleSettings.StopOnIdleEnd $aResult[$iRows][62] = $oIdleSettings.WaitTimeout ; NetworkSettings object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382067%28v=vs.85%29.aspx $oTaskNetworkSettings = $oTaskSettings.NetworkSettings $aResult[$iRows][63] = ( $oTaskNetworkSettings.Id = "0" ? "" : $oTaskNetworkSettings.Id ) $aResult[$iRows][64] = ( $oTaskNetworkSettings.Name = "0" ? "" : $oTaskNetworkSettings.Name ) ; Trigger object ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa383868%28v=vs.85%29.aspx $colTaskTriggers = $oTaskDefinition.Triggers For $oTaskTriggers in $colTaskTriggers $aResult[$iRows][65] = $oTaskTriggers.Enabled $aResult[$iRows][66] = ( $oTaskTriggers.Id = "0" ? "" : $oTaskTriggers.Id ) $aResult[$iRows][67] = ( $oTaskTriggers.StartBoundary = "0" ? "" : $oTaskTriggers.StartBoundary ) $aResult[$iRows][68] = ( $oTaskTriggers.EndBoundary = "0" ? "" : $oTaskTriggers.EndBoundary ) $aResult[$iRows][69] = ( $oTaskTriggers.ExecutionTimeLimit = "0" ? "" : $oTaskTriggers.ExecutionTimeLimit ) $aResult[$iRows][70] = $oTaskTriggers.Type & "-" & ( $oTaskTriggers.Type = 0 ? "Event" : _ ( $oTaskTriggers.Type = 1 ? "Time" : _ ( $oTaskTriggers.Type = 2 ? "Daily" : _ ( $oTaskTriggers.Type = 3 ? "Weekly" : _ ( $oTaskTriggers.Type = 4 ? "Monthly" : _ ( $oTaskTriggers.Type = 5 ? "Monthly on Specific Day" : _ ( $oTaskTriggers.Type = 6 ? "When Computer is idle" : _ ( $oTaskTriggers.Type = 7 ? "When Task is registered" : _ ( $oTaskTriggers.Type = 8 ? "Boot" : _ ( $oTaskTriggers.Type = 9 ? "Logon" : _ "Session State Change" ) ) ) ) ) ) ) ) ) ) $aResult[$iRows][71] = $oTaskTriggers.Delay $aResult[$iRows][72] = $oTaskTriggers.Subscription $aResult[$iRows][73] = $oTaskTriggers.DaysInterval $aResult[$iRows][74] = $oTaskTriggers.WeeksInterval $aResult[$iRows][75] = $oTaskTriggers.DaysOfWeek ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa384024%28v=vs.85%29.aspx $aResult[$iRows][76] = $oTaskTriggers.DaysOfMonth ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382063%28v=vs.85%29.aspx $aResult[$iRows][77] = $oTaskTriggers.MonthsOfYear ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382064%28v=vs.85%29.aspx $aResult[$iRows][78] = $oTaskTriggers.RandomDelay $aResult[$iRows][79] = $oTaskTriggers.RunOnLastDayOfMonth $aResult[$iRows][80] = $oTaskTriggers.WeeksOfMonth ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382061%28v=vs.85%29.aspx $aResult[$iRows][81] = $oTaskTriggers.UserId $aResult[$iRows][82] = ( $oTaskTriggers.StateChange = 0 ? "0" : $oTaskTriggers.StateChange ) & "-" & ( $oTaskTriggers.StateChange = 0 ? "None" : _ ( $oTaskTriggers.StateChange = 1 ? "User Session Connect to Local Computer" : _ ( $oTaskTriggers.StateChange = 2 ? "User Session Disconnect from Local Computer" : _ ( $oTaskTriggers.StateChange = 3 ? "User Session Connect to Remote Computer" : _ ( $oTaskTriggers.StateChange = 4 ? "User Session Disconnect from Remote Computer" : _ ( $oTaskTriggers.StateChange = 7 ? "On Workstation Lock" : _ "On Workstation Unlock" ) ) ) ) ) ) $oTaskRepetition = $oTaskTriggers.Repetition $aResult[$iRows][83] = $oTaskRepetition.Duration $aResult[$iRows][84] = $oTaskRepetition.Interval $aResult[$iRows][85] = $oTaskRepetition.StopAtDurationEnd Next $aResult[$iRows][86] = .xml EndWith Next Next Return $aResult EndFunc ;==>_TaskListAllDetailed ; #FUNCTION# ==================================================================================================== ; Function ......: _TaskGetFolders(ByRef $aFolders[, $sFolder = "\"[, $bRecurse = True[, $iDepth = 0]]]) ; Description ...: returns an array of all folders as from a given Scheduler Library folder recursively ; Parameters ....: $aFolders - Empty array passed by reference (array must be declared Global at the start of the script) ; $sFolders - Optional: Path to scheduled Tasks (default = "\") ; $bRecurse - Optional: Recurse all folders as from $sFolder path (default = True) ; $iDepth - Internal use only! ; Return values .: Success - Returns $aFolders populated with scheduled tasks folders ; Failure - Returns 0 and sets @error: ; |1 - $oService is not an object ; |2 - $oFolder is not an object ($sFolder folder does not exist) ; |3 - $oFolders is not an object ; |4 - $bRecurse is not boolean ; |5 - $iDepth is not an integer ; Authors........: GreenCan ; Complement to..: allow2010 UDF ; Remarks .......: Compatible with Win7 and above ; Link ..........: http://www.autoitscript.com/forum/topic/135994-taskplanner-udf/ ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa382542%28v=vs.85%29.aspx ; Example .......: Global $aFolders ; required! ; _TaskGetFolders($aFolders) ; _TaskGetFolders($aFolders, "\OfficeSoftwareProtectionPlatform") ; _TaskGetFolders($aFolders, "\Microsoft\Windows") ; _ArrayDisplay($aFolders, "Task Scheduler Folders") ; =============================================================================================================== Func _TaskGetFolders(ByRef $aFolders, $sFolder = "\", $bRecurse = True, $iDepth = 0) If Not IsBool($bRecurse) Then Return SetError(4, 0, 0) If Not IsInt($iDepth) Then Return SetError(5, 0, 0) Local $oService, $oFolder, $oFolders, $oSubFolders $oService = ObjCreate("Schedule.Service") If Not IsObj($oService) Then Return SetError(1, 0, 0) $oService.Connect() $oFolder = $oService.GetFolder($sFolder) If Not IsObj($oFolder) Then Return SetError(2, 0, 0) $oFolders = $oFolder.GetFolders(0) If Not IsObj($oFolder) Then Return SetError(3, 0, 0) If $iDepth = 0 Then Dim $aFolders[2] $aFolders[0] = 1 $aFolders[1] = $sFolder EndIf For $oItem In $oFolders With $oItem ;ConsoleWrite( .Name & " ==> " & .Path & @CRLF) ReDim $aFolders[$aFolders[0] + 2] $aFolders[0] += 1 $aFolders[$aFolders[0]] = .Path If $bRecurse Then _TaskGetFolders($aFolders, .Path, True, $iDepth + 1) ; Get all subfolders EndWith Next Return $aFolders EndFunc ;==>_TaskGetFolder #Region Internal functions Func __DaysOfWeek($iValue) Local $sDays = "" If BitAND($iValue,1) Then $sDays &= "Sunday," If BitAND($iValue,2) Then $sDays &= "Monday," If BitAND($iValue,4) Then $sDays &= "Tuesday," If BitAND($iValue,8) Then $sDays &= "Wednesday," If BitAND($iValue,16) Then $sDays &= "Thursday," If BitAND($iValue,32) Then $sDays &= "Friday," If BitAND($iValue,64) Then $sDays &= "Saturday," Return StringTrimRight($sDays, 1) EndFunc ;==>__DaysOfWeek Func __DaysOfMonth($iValue) Local $sDays = "" If BitAND($iValue,1) Then $sDays &= "1," If BitAND($iValue,2) Then $sDays &= "2," If BitAND($iValue,4) Then $sDays &= "3," If BitAND($iValue,8) Then $sDays &= "4," If BitAND($iValue,16) Then $sDays &= "5," If BitAND($iValue,32) Then $sDays &= "6," If BitAND($iValue,64) Then $sDays &= "7," If BitAND($iValue,128) Then $sDays &= "8," If BitAND($iValue,256) Then $sDays &= "9," If BitAND($iValue,512) Then $sDays &= "10," If BitAND($iValue,1024) Then $sDays &= "11," If BitAND($iValue,2048) Then $sDays &= "12," If BitAND($iValue,4096) Then $sDays &= "13," If BitAND($iValue,8192) Then $sDays &= "14," If BitAND($iValue,16384) Then $sDays &= "15," If BitAND($iValue,32768) Then $sDays &= "16," If BitAND($iValue,65536) Then $sDays &= "17," If BitAND($iValue,131072) Then $sDays &= "18," If BitAND($iValue,262144) Then $sDays &= "19," If BitAND($iValue,524288) Then $sDays &= "20," If BitAND($iValue,1048576) Then $sDays &= "21," If BitAND($iValue,2097152) Then $sDays &= "22," If BitAND($iValue,4194304) Then $sDays &= "23," If BitAND($iValue,8388608) Then $sDays &= "24," If BitAND($iValue,16777216) Then $sDays &= "25," If BitAND($iValue,33554432) Then $sDays &= "26," If BitAND($iValue,67108864) Then $sDays &= "27," If BitAND($iValue,134217728) Then $sDays &= "28," If BitAND($iValue,268435456) Then $sDays &= "29," If BitAND($iValue,536870912) Then $sDays &= "30," If BitAND($iValue,1073741824) Then $sDays &= "31," If BitAND($iValue,2147483648) Then $sDays &= "Last," Return StringTrimRight($sDays, 1) EndFunc ;==>__DaysOfMonth Func __WeeksOfMonth($iValue) Local $sWeek = "" If BitAND($iValue,1) Then $sWeek &= "First," If BitAND($iValue,2) Then $sWeek &= "Second," If BitAND($iValue,4) Then $sWeek &= "Third," If BitAND($iValue,8) Then $sWeek &= "Fourth," Return StringTrimRight($sWeek, 1) EndFunc ;==>__WeeksOfMonth Func __MonthsOfYear($iValue) Local $sMonths = "" If BitAND($iValue,1) Then $sMonths &= "January," If BitAND($iValue,2) Then $sMonths &= "February," If BitAND($iValue,4) Then $sMonths &= "March," If BitAND($iValue,8) Then $sMonths &= "April," If BitAND($iValue,16) Then $sMonths &= "May," If BitAND($iValue,32) Then $sMonths &= "June," If BitAND($iValue,64) Then $sMonths &= "July," If BitAND($iValue,128) Then $sMonths &= "August," If BitAND($iValue,256) Then $sMonths &= "September," If BitAND($iValue,512) Then $sMonths &= "October," If BitAND($iValue,1024) Then $sMonths &= "November," If BitAND($iValue,2048) Then $sMonths &= "December," Return StringTrimRight($sMonths, 1) EndFunc ;==>__MonthsOfYear #EndRegion Internal functions Func _TaskListToText($aTasks) ; create formatted output of scheduled tasks If Not IsArray($aTasks) Then Return SetError(1, 0, 0) If UBound($aTasks) < 2 Then Return SetError(2, 0, 0) Local $sOutput = "", $hFile For $i = 1 to $aTasks[0][0] $sOutput &= "Task Name(" & $i & "): " & $aTasks[$i][0] & @CRLF $sOutput &= @TAB & "Enabled: " & $aTasks[$i][1] & @CRLF $sOutput &= @TAB & "LastRunTime: " & $aTasks[$i][2] & @CRLF $sOutput &= @TAB & "LastTaskResult: " & $aTasks[$i][3] & @CRLF $sOutput &= @TAB & "NextRunTime: " & $aTasks[$i][4] & @CRLF $sOutput &= @TAB & "NumberOfMissedRuns: " & $aTasks[$i][5] & @CRLF $sOutput &= @TAB & "Path: " & $aTasks[$i][6] & @CRLF $sOutput &= @TAB & "Task State: " & $aTasks[$i][7] & @CRLF $sOutput &= @TAB & "1. Actions" & @CRLF $sOutput &= @TAB & " -Id: " & $aTasks[$i][9] & @CRLF $sOutput &= @TAB & " -Type: " & $aTasks[$i][10] & @CRLF If StringLeft($aTasks[$i][10], 1) = "0" Then ; execute command line operation $sOutput &= @TAB & " -Arguments: " & $aTasks[$i][11] & @CRLF $sOutput &= @TAB & " -Path: " & $aTasks[$i][12] & @CRLF $sOutput &= @TAB & " -WorkingDirectory: " & $aTasks[$i][13] & @CRLF ElseIf StringLeft($aTasks[$i][10], 1) = "5" Then ; Represents an action that fires a handler, don't know what this is... $sOutput &= @TAB & " -ClassId: " & $aTasks[$i][14] & @CRLF $sOutput &= @TAB & " -Data: " & $aTasks[$i][15] & @CRLF ElseIf StringLeft($aTasks[$i][10], 1) = "6" Then ; Send an e-mail $sOutput &= @TAB & " -e-mailFrom: " & $aTasks[$i][16] & @CRLF $sOutput &= @TAB & " -ReplyTo: " & $aTasks[$i][17] & @CRLF $sOutput &= @TAB & " -To: " & $aTasks[$i][18] & @CRLF $sOutput &= @TAB & " -CC: " & $aTasks[$i][19] & @CRLF $sOutput &= @TAB & " -BCC: " & $aTasks[$i][20] & @CRLF $sOutput &= @TAB & " -Subject: " & $aTasks[$i][21] & @CRLF $sOutput &= @TAB & " -Body: " & $aTasks[$i][22] & @CRLF $sOutput &= @TAB & " -Server: " & $aTasks[$i][23] & @CRLF $sOutput &= @TAB & " -Attachments: " & $aTasks[$i][24] & @CRLF ElseIf StringLeft($aTasks[$i][10], 1) = "7" Then ; display a message $sOutput &= @TAB & " -MsgBoxTitle: " & $aTasks[$i][25] & @CRLF $sOutput &= @TAB & " -MessageBody: " & $aTasks[$i][26] & @CRLF EndIf $sOutput &= @TAB & "2. Principal" & @CRLF $sOutput &= @TAB & " -ID: " & $aTasks[$i][27] & @CRLF $sOutput &= @TAB & " -DisplayName: " & $aTasks[$i][28] & @CRLF $sOutput &= @TAB & " -GroupId: " & $aTasks[$i][29] & @CRLF $sOutput &= @TAB & " -LogonType: " & $aTasks[$i][30] & @CRLF $sOutput &= @TAB & " -RunLevel: " & $aTasks[$i][31] & @CRLF $sOutput &= @TAB & " -UserId: " & $aTasks[$i][32] & @CRLF $sOutput &= @TAB & "3. Registration Info" & @CRLF $sOutput &= @TAB & " -Author: " & $aTasks[$i][33] & @CRLF $sOutput &= @TAB & " -Date: " & $aTasks[$i][34] & @CRLF $sOutput &= @TAB & " -Description: " & $aTasks[$i][35] & @CRLF $sOutput &= @TAB & " -Documentation: " & $aTasks[$i][36] & @CRLF $sOutput &= @TAB & " -SecurityDescriptor: " & $aTasks[$i][37] & @CRLF $sOutput &= @TAB & " -Source: " & $aTasks[$i][38] & @CRLF $sOutput &= @TAB & " -URI: " & $aTasks[$i][39] & @CRLF $sOutput &= @TAB & " -Version: " & $aTasks[$i][40] & @CRLF $sOutput &= @TAB & "4. Task Setting" & @CRLF $sOutput &= @TAB & " -AllowDemandStart: " & $aTasks[$i][41] & @CRLF $sOutput &= @TAB & " -AllowHardTerminate: " & $aTasks[$i][42] & @CRLF $sOutput &= @TAB & " -Compatibility: " & $aTasks[$i][43] & @CRLF $sOutput &= @TAB & " -DeleteExpiredTaskAfter: " & $aTasks[$i][44] & @CRLF $sOutput &= @TAB & " -DisallowStartIfOnBatteries: " & $aTasks[$i][45] & @CRLF $sOutput &= @TAB & " -Enabled: " & $aTasks[$i][46] & @CRLF $sOutput &= @TAB & " -ExecutionTimeLimit: " & $aTasks[$i][47] & @CRLF $sOutput &= @TAB & " -Hidden: " & $aTasks[$i][48] & @CRLF $sOutput &= @TAB & " -MultipleInstances: " & $aTasks[$i][49] & @CRLF $sOutput &= @TAB & " -Priority (0=High - 10= Low): " & $aTasks[$i][50] & @CRLF $sOutput &= @TAB & " -RestartCount: " & $aTasks[$i][51] & @CRLF $sOutput &= @TAB & " -RestartInterval: " & $aTasks[$i][52] & @CRLF $sOutput &= @TAB & " -RunOnlyIfIdle: " & $aTasks[$i][53] & @CRLF $sOutput &= @TAB & " -RunOnlyIfNetworkAvailable: " & $aTasks[$i][54] & @CRLF $sOutput &= @TAB & " -StartWhenAvailable: " & $aTasks[$i][55] & @CRLF $sOutput &= @TAB & " -StopIfGoingOnBatteries: " & $aTasks[$i][56] & @CRLF $sOutput &= @TAB & " -WakeToRun: " & $aTasks[$i][57] & @CRLF $sOutput &= @TAB & " -IdleSettings: " & $aTasks[$i][58] & @CRLF $sOutput &= @TAB & @TAB & " -IdleDuration: " & $aTasks[$i][59] & @CRLF $sOutput &= @TAB & @TAB & " -RestartOnIdle: " & $aTasks[$i][60] & @CRLF $sOutput &= @TAB & @TAB & " -StopOnIdleEnd: " & $aTasks[$i][61] & @CRLF $sOutput &= @TAB & @TAB & " -WaitTimeout: " & $aTasks[$i][62] & @CRLF $sOutput &= @TAB & "5. Network Settings" & @CRLF $sOutput &= @TAB & " -Id: " & $aTasks[$i][63] & @CRLF $sOutput &= @TAB & " -Name: " & $aTasks[$i][64] & @CRLF $sOutput &= @TAB & "6. Trigger" & @CRLF $sOutput &= @TAB & " -Enabled: " & $aTasks[$i][65] & @CRLF $sOutput &= @TAB & " -Id: " & $aTasks[$i][66] & @CRLF $sOutput &= @TAB & " -StartBoundary: " & $aTasks[$i][67] & @CRLF $sOutput &= @TAB & " -EndBoundary: " & $aTasks[$i][68] & @CRLF $sOutput &= @TAB & " -ExecutionTimeLimit: " & $aTasks[$i][69] & @CRLF $sOutput &= @TAB & " -Type: " & $aTasks[$i][70] & @CRLF If StringLeft($aTasks[$i][70], 1) = "0" Then ; Event $sOutput &= @TAB & " -Delay: " & $aTasks[$i][71] & @CRLF $sOutput &= @TAB & " -Subscription: " & $aTasks[$i][72] & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "1" Then ; Time ElseIf StringLeft($aTasks[$i][70], 1) = "2" Then ; Daily $sOutput &= @TAB & " -DaysInterval: " & $aTasks[$i][73] & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "3" Then ; Weekly $sOutput &= @TAB & " -WeeksInterval: " & $aTasks[$i][74] & @CRLF $sOutput &= @TAB & " -DaysOfWeek: " & $aTasks[$i][75] & " (" & __DaysOfWeek($aTasks[$i][75]) & ")" & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "4" Then ; Monthly $sOutput &= @TAB & " -DaysOfMonth: " & $aTasks[$i][76] & " (" & __DaysOfMonth($aTasks[$i][76]) & ")" & @CRLF $sOutput &= @TAB & " -MonthsOfYear: " & $aTasks[$i][77] & " (" & __MonthsOfYear($aTasks[$i][77]) & ")" & @CRLF $sOutput &= @TAB & " -RandomDelay: " & $aTasks[$i][78] & @CRLF $sOutput &= @TAB & " -RunOnLastDayOfMonth: " & $aTasks[$i][79] & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "5" Then ; Monthly on Specific Day $sOutput &= @TAB & " -DaysOfWeek: " & $aTasks[$i][75] & " (" & __DaysOfWeek($aTasks[$i][75]) & ")" & @CRLF $sOutput &= @TAB & " -MonthsOfYear: " & $aTasks[$i][77] & " (" & __MonthsOfYear($aTasks[$i][77]) & ")" & @CRLF $sOutput &= @TAB & " -RandomDelay: " & $aTasks[$i][78] & @CRLF $sOutput &= @TAB & " -RunOnLastDayOfMonth: " & $aTasks[$i][79] & @CRLF $sOutput &= @TAB & " -WeeksOfMonth: " & $aTasks[$i][80] & " (" & __WeeksOfMonth($aTasks[$i][80]) & ")" & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "6" Then ; When Computer is idle ElseIf StringLeft($aTasks[$i][70], 1) = "7" Then ; When Task is registered $sOutput &= @TAB & " -Delay: " & $aTasks[$i][71] & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "8" Then ; Boot $sOutput &= @TAB & " -Delay: " & $aTasks[$i][71] & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "9" Then ; Logon $sOutput &= @TAB & " -Delay: " & $aTasks[$i][71] & @CRLF $sOutput &= @TAB & " -UserId: " & $aTasks[$i][81] & @CRLF ElseIf StringLeft($aTasks[$i][70], 1) = "11" Then ; Session State Change $sOutput &= @TAB & " -StateChange: " & $aTasks[$i][82] & @CRLF $sOutput &= @TAB & " -Delay: " & $aTasks[$i][71] & @CRLF $sOutput &= @TAB & " -UserId: " & $aTasks[$i][81] & @CRLF EndIf $sOutput &= @TAB & " -Repetition: " & @CRLF $sOutput &= @TAB & @TAB & " -Duration: " & $aTasks[$i][83] & @CRLF $sOutput &= @TAB & @TAB & " -Interval: " & $aTasks[$i][84] & @CRLF $sOutput &= @TAB & @TAB & " -StopAtDurationEnd: " & $aTasks[$i][85] & @CRLF & @CRLF $sOutput &= "XML: " & @CRLF & $aTasks[$i][86] & @CRLF $sOutput &= "===============================================================================" & @CRLF Next $hFile=fileopen("Scheduled tasks.txt", 2) FileWrite($hFile, $sOutput) Fileclose($hFile) EndFunc ;==>_TaskListtext