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?

link|improve this question

78% accept rate
feedback

closed as exact duplicate by Revolter, techie007, ChrisF, studiohack Dec 1 '11 at 5:51

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

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.

link|improve this answer
feedback

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.

link|improve this answer
feedback

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