I have a task in task scheduler and I want to run this task once the screen sleeps not the computer. I’ve tried setting the Trigger to be “On Idle” but didn’t work, and I tried setting the trigger to be “On an event” and chose Log “System” and source ID to “Kernel-Power” and Event ID to “42” but still didn’t work as it works when the system itself sleeps not the screen. Could anyone please advise how I can run the task when then screen go to sleep not the PC itself?
Windows Task Scheduler – Run a Task When Screen Sleeps
eventssleeptask schedulerwindowswindows task scheduler
Related Solutions
There are several things you need to watch for when you schedule a task.
One of the main ones I found is the timing.
For example, let's say it's 0018h right now and you schedule a task to run at 0000h daily every 5 minutes. You make all settings, put all conditions, test-start the task and it's fine, all seems good but the task will not start even if the conditions are met. That happens because of the exceeded schedule. It will only start at the next 0000h. So if it's 0018h and you actually want to see the task working, put it at an immediately later time instead, like 0024h and make sure that the set time is not exceeded while you're configuring it.
Then, you can make sure other conditions are fine, like the ones related to power-states, network availability, success state.
Another very important aspect: make sure the credentials used to run it have enough privileges to actually run it. That part is easier to check because you can manually test it.
Microsoft basically programmed Windows to say: A computer is considered Idle if for 4 minutes, no user input was generated.
What this means is this: Windows starts detecting that a system is idle but ignores it for 4 minutes. The exact reason why is unknown, but it is probably for optimization reasons and possible complaints. When the system becomes in Idle state after 4 minutes, the OS announces: the system is now idle for 4 minutes, and counting...
Task scheduler gets the message, sees your task which is set, idle for 1 minute and thinks: Oh, we should've started you 3 minutes ago. Lets start you now. In windows 7, it doesn't care for the 3 previous minutes.
This gives you 2 options.
- Accept that there always will be a delay of 4 minutes
- Don't use Task Scheduler. Instead create a program or script that measures activity and perform the launching of the task yourself. Do note that this will increase the overhead of the system and may hurt performance if coded inproperly.
My recommendation would be to go for option 1. Just accept that there is a 4 minute delay. Your initial question was 30 minutes anyway.
Best Answer
There are no consistent events triggered based on screen power state changes, therefore there is no way to trigger a task based on this.