mindclutter54 Posted July 17, 2017 Share Posted July 17, 2017 (edited) Hi everybody, I'm fairly new to AutoIt, need some help with something. So I recently wrotea script using OutlookEX that will run a batch file on my PC after receiving an email with a specific subject from a specific email address. Thing is, I also need to make sure that a different windows task has run AND completed. I can't simply run the script after the original task as it's possible that the email has already arrived by the time the other task completes, so right now I'm running the script at the beginning of the one that I need to complete. Any ideas on how to do this? I've seen several examples for creating/deleting tasks, etc, but nothing that will give me the logs showing that the date/time the task last completed successfully. If there's already another thread out there with this info, I apologize...I've been searching for several days now to no avail. Thanks, mc54 Edited July 24, 2017 by mindclutter54 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 17, 2017 Moderators Share Posted July 17, 2017 (edited) You could do something like this to check the last time your task ran (works, but no error checking): Local $oService , $rootFolder, $oTasks, $iNum, $sName, $sState = 0 $oService = ObjCreate("Schedule.Service") $oService.Connect() $rootFolder = $oService.GetFolder("\") $oTasks = $rootFolder.GetTasks(0) $iNum = $oTasks.Count If $iNum = 0 Then ConsoleWrite("No Tasks Found" & @CRLF) Else ConsoleWrite($iNum & " tasks found:" & @CRLF) For $sTask in $oTasks Switch $sTask.State Case 0 $sState = "Unknown" Case 1 $sState = "Disabled" Case 2 $sState = "Queued" Case 3 $sState = "Ready" Case 4 $sState = "Running" EndSwitch ConsoleWrite("For task " & $sTask.Name & ", status is: " & $sState & " " & $sTask.LastRunTime & @CRLF) Next EndIf Edit: I just noticed you mentioned successful runs, you could get this with the .LastTaskResult. You could do something like: If $oTask.LastTaskResult <> 0 Then ... Edited July 17, 2017 by JLogan3o13 mLipok 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
mindclutter54 Posted July 20, 2017 Author Share Posted July 20, 2017 Thank you very much, works perfectly! I can't believe after so many years that I had never heard of AutoIt until a week or two ago. I've barely scratched the surface and I love this program. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 20, 2017 Moderators Share Posted July 20, 2017 Glad you got your issue resolved. And yes, it is a great language to have in your scripting repository "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now