6

Possible Duplicate:
Is there any way to execute something when closing the laptop's lid?

I have a task that I want to run right before my computer sleeps or hibernates. Is there a way to schedule a task for this in the Windows 7 task scheduler?

The closest that I can see is for on locking the workstation, and this works as a surrogate, but I really don't want it to run on locking unless it is also sleeping/hibernating. Is there a way to schedule for an event like this?

fixer1234
  • 28,064
Andrew Redd
  • 1,772

2 Answers2

5

I think your best bet is to configure the task to shut down or hibernate your computer when it finishes, and then start the task directly instead of stopping your computer. For example, write a batch file that runs the process and then shuts down the machine, and then run that batch file.

jcrawfordor
  • 16,449
1

Found the answer in this question which sites a technet article. The Jist of it is that no the windows 7 is restricted to the list given, but you can attach a task to the sleep/hibernate/shutdown events through the task scheduler. Schedule with the trigger as a log event. For sleep use; Log= System, Source= Kernel-Power, Event ID= 42. And for shutdown System/Security/513.

Andrew Redd
  • 1,772