12

I created a task in Task Scheduler to run at system startup, and it works great. However, I want to change it to run every time Windows wakes from sleep and I cannot figure it out. The relevant options available to me are at startup (currently), at log on, on an event. Perhaps I need to select on an event and find an event that happens when the computer wakes?

1
  • 1
    If the task is not starting after waking up, try checking “Run task as soon as possible after a scheduled start is missed” and see if that helps. Other than that, review existing tasks to see if there is an On Event trigger that will help.
    – anon
    Commented Jul 15, 2021 at 22:43

4 Answers 4

12

You should definitely go for the "event" option. You could try the event with the following properties:

Event-Log: System
Source: Power-Troubleshooter
Event-Code: 1

This one is issued every time the system wakes up from sleeping mode (suspend-to-ram). Not sure if it will work for hibernate.

Also if this event is not good for any reason, you could try finding other events. Just send your system into sleep mode, wake it up, and then look for anything related to power in the "System" event log.

3
  • Where can we find a list of ALL these events, specifically ones like these that Task Scheduler can listen to? All the search terms I'm trying are too darn generic to find references online. TY!
    – Chazbot
    Commented Mar 19, 2023 at 1:10
  • @Chazbot I don'n think such list exists. Also, no software listens to these events, they are just logs. They are emitted by various software and just saved by Event Logger.
    – trolzen
    Commented Mar 20, 2023 at 17:13
  • 4
    Also, I can confirm that the same trigger fires when waking the system up from hibernate. Thanks for the answer!
    – Gamrix
    Commented Jul 24, 2023 at 2:10
3

Sleep then wake up your system.

Open Event viewer then click Windows Log > System

Look at top information's souce and id.

Enter this event log ,source and event code information as trigger

In intel my conf:

Event-Log: System
Source: Kernel-Power
Event-Code: 507
2

On my AMD system the "Power-Troubleshooter" event did not work. What worked was:

Event-Log: System

Source: Kernel-Power

Event-Code: 107

1

If you don't object to using a third party (paid) program, it appears Macro Express™ will do as you require. There's a support post for restarting Dropbox when the machine awakes. The advice is specific to the program, but to avoid broken links:

How it works - System Event activation Windows sends messages when certain events occur. When Windows wakes up from sleep, a WM_POWERBROADCAST message is sent with the message's wParam set to PBT_APMRESUMEAUTOMATIC. By creating a macro with a System Event activation with these values a macro will run when Windows wakes up.

Macros can be set to run when other system events occur. All that is needed is to find the correct message values for the event. Reference pages document the values for system messages. Message values may be shown in decimal (536) or hexadecimal (0x218) formats, but the system Event macro activation expects decimal values.

The WM_POWERBROADCAST value is 536 decimal and the PBT_APMRESUMEAUTOMATIC value for wParam is 18 decimal. These values are used in this macro to run when Windows wakes up.

The support document is a focus on Dropbox, but my experience with Macro Express™ suggests that changing one line of the code (program name/location) will be an easy edit. The document also includes a download of the .MEX file, the native format of a saved macro.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .