5

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?

2
  • 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.
    – John
    Jul 15, 2021 at 22:43
  • @acidgate so have any of these answers helped you?
    – trolzen
    Jul 18, 2021 at 22:16

2 Answers 2

5

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.