1

This is a follow-up to How do I determine logon/logoff times in Windows Powershell without admin rights?

I learned recently how to schedule tasks with Windows' Task Scheduler, and I was able to schedule a task that runs on log on and log off events.

However, I incorrectly assumed that putting a laptop to sleep would be "folded in" to the log off event. Trial of my on-logoff-task shows that it successfully runs when I explicitly lock my laptop (e.g. Win+L), but it does not run when I put my laptop to sleep.

Scheduling a task before sleep in Windows 7 and hold off the sleep event until task runs led me to learn about the PBT_APMSUSPEND event, which seems like what I need, but I can't figure out how to select that as my trigger in Task Scheduler. Can a knowledgeable user please advise what I need to do in the Task Scheduler/Edit Trigger GUI to create a task that runs on the PBT_APMSUSPEND event?

enter image description here

StoneThrow
  • 1,317

1 Answers1

1

Look for this event in Event Viewer, and just right click on the event, and select "Attach a Task to this event." More instructions here

Aron Einhorn
  • 396
  • 2
  • 3