I have set a task to run a .bat file which runs 2 Python files. This works successfully when I run it manually, and I have set it to wake up the computer (a desktop plugged into a UPS) twice a day 12 hours apart and run. Normally it does wake up the computer around the scheduled time, give or take about 5 minutes, and run the task even at the login screen, which can take up to about 10 to 15 minutes. At the end of the .bat file, there is a hibernate command. Whether the computer hibernates by this or when I manually hibernate it by clicking on the Start Menu -> Hibernate, the task wakes the computer up at the next scheduled time even if it's like half a day later and the process repeats. But I notice after almost a week, the computer turns on around the task-scheduled time but there's no indication if the .bat file has run this time. I got this computer as brand new a few years ago and have kept it updated. There was no power outage as I'm pretty sure the UPS was still running on power rather than battery solely, and I didn't touch the computer during this process. This was only 1 of the few tasks I've created as I have about 3 or so tasks and they are not scheduled around the same time. I did see some other tasks set/executing around the same time that seemed like they were set by the system (e. g. MicrosoftEdgeUpdateTaskMachineUA, etc.).
When I checked the history logs for the task, I saw this from latest to oldest:
Task Scheduler successfully finished "{...}" instance of the "\task1" task for user "......".
Task Scheduler successfully completed task "\task1" , instance "{...}" , action "C:\WINDOWS\SYSTEM32\cmd.exe" with return code 0.
Normally when the task runs the .bat file successfully before hibernating the computer, these are the logs I may see instead from latest to oldest:
Task Scheduler launched action "C:\WINDOWS\SYSTEM32\cmd.exe" in instance "{...}" of task "\task1".
Task Scheduler started "{...}" instance of the "\task1" task for user "......".
Task Scheduler launch task "\task1" , instance "C:\WINDOWS\SYSTEM32\cmd.exe" with process ID ....
Task Scheduler launched "{...}" instance of task "\task1" due to a time trigger condition.
My settings for the task are as follows:
- Run only when user is logged on
- Run with highest privileges
- 2 daily triggers enabled
- Actions Tab
- Start a program: task1.bat
- Start in (optional): C:\Users...\Documents\folder1
- Start the task only if the computer is on AC power
- Stop if the computer switches to battery power
- Wake the computer to run this task
- Allow task to be run on demand
- Run task as soon as possible after a scheduled start is missed
- If the task fails, restart every: 5 minutes
- Attempt to restart up to: 3 times
- Stop the task if it runs longer than 4 hours
- If the running task does not end when requested, force it to stop
- If the task is already running, then the following rule applies: Stop the existing instance