13

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?

4 Answers4

18

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.

trolzen
  • 506
5

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
Hakan
  • 181
3

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.

fred_dot_u
  • 2,902
  • 1
  • 15
  • 10