Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

marked as duplicate by Revolter, Ƭᴇcʜιᴇ007, ChrisF, studiohack Dec 1 '11 at 5:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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.

share|improve this answer

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.

share|improve this answer
Doesn't seem to work when the laptop power is not plugged in though. – ThreaT Aug 27 '14 at 19:28

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