Trigger Task Scheduler in Windows 7 when computer wakes up from sleep/hibernate

32

13

I don't want task scheduler or whatever to wake the computer, but when I open the laptop back up and the machine wakes I'd like that to be the trigger that task scheduler or something uses to run an app.

Adam

Posted 2009-12-17T06:47:52.533

Reputation: 596

Answers

25

You can tick the “Run task as soon as possible after a scheduled start is missed” checkbox on the Settings tab for the task. That's for tasks at least that are scheduled regularly and fail to start due to sleep/hibernate/shutdown.

There doesn't seem to be a trigger "On waking from sleep", but you can probably use the “On Event” trigger. The interesting events seem to be from “Kernel-Power” and “Power-Troubleshooter”. System sleep generates an event from Kernel-Power with event ID 42. Wakeup is an event from Power-Troubleshooter with event ID 1.

Joey

Posted 2009-12-17T06:47:52.533

Reputation: 36 381

1This doesn't seem to work when the laptop power cable is unplugged though? – ThreaT – 2014-08-27T19:29:48.183

1To clarify, listen to event ID 42 in System log from source Kernel-Power as the sleeping event, and the event ID 1 in System log from source Power-Troubleshooter for computer's resuming (waking). – Gene Pavlovsky – 2016-10-02T22:25:30.167

@ThreaT In Task Scheduler, in the Conditions tab, uncheck "Start the task only if the computer is on AC power" – tubbie – 2017-07-18T08:06:01.560

as @anno My System journal does not have any Power-Troubleshooter event ID 1. I tried to use "Kernel-Power event ID 1 - Time synced" but it raises long after wake, in my case task resumes OS at 7:00 but "Kernel-Power event ID 1" occurs only at 8:32 and 17:32. So it's not reliable. Is there any system registry switch to enable wake reporting to the log? – Dr.eel – 2018-10-05T18:56:00.880

"Kernel-Power with event ID 42" worked for me on Windows 7 when activating a bat-file on return from sleep mode – None – 2011-11-24T11:05:33.863

For wake-up, Power-Troubleshooter did not work for me. The only event that gets fired is Kernel-General with ID 1. – anno – 2012-04-04T12:53:39.333

Perhaps I'm not talking about the right even, but I can't seem to get it to work. Basically I'm looking to start the task after putting the notebook computer to sleep (or whatever the actual state happens to be) when I reopen the lid and it comes back on.

Usually at this point I have to type in the user password to get access to the system. I've played around with some of the event that seemed relevant to that as well, with no luck. – Adam – 2009-12-22T17:50:58.717

22

The event-based solution suggested by Johannes worked well for me. I wanted a certain text file (my to do list) to open in Notepad every time I un-hibernated my computer (Windows 7). I set up a scheduled task to run with this event as a trigger:

  • Log: System
  • Source:Power-Troubleshooter
  • Event ID: 1

This is working well for me.

Rangi Robinson

Posted 2009-12-17T06:47:52.533

Reputation: 321

3

Event 107 when resumed from sleep, and 42 from entering to sleep. I just try event 107 to trigger a program when resume from sleep, and it worked

enter image description here

enter image description here

Schedule tasks

HelloWindowsPhone

Posted 2009-12-17T06:47:52.533

Reputation: 131

0

There is a simpler method: Triggers > New > On workstation unlock > Any user. When putting the computer to sleep, you're actually (also) locking the machine, and on waking up you will see 'Locked' above the password field, assuming you're using a password.

Frank Conijn

Posted 2009-12-17T06:47:52.533

Reputation: 129

a) this is not what the OP asked for b) it might not be desirable to run it on that event -- depends on the use case – elonderin – 2020-02-25T16:27:57.160

0

Below is an AutoHotkey solution based on a similar question

Save the (one line) script below with file ending .ahk:

Send {Volume_Down 100} ; Turns the volume DOWN 100 intervals

To run it on login or when the computer wakes, there is a AutoHotkey script that attempts to solve this here, or you can run the script using Task Scheduler.

More information can be found here (control volume) and here (for using AutoHotkey).

Stenemo

Posted 2009-12-17T06:47:52.533

Reputation: 266