Is there a scripting possibility or application, free or commercially avaible, that would allow me to set up windows to close a partuicular application before it goes to sleep mode?


You can create a Scheduled Task in Windows' Task Scheduler.

There is an "When a specific event is logged" trigger available. The event you need to trigger on is in the "System" log with the Source "USER32" and Event Id 1074. This event is logged whenever the system shuts down or goes into hibernation.

As for the shutting down a particular application you add an action the the Scheduled Task which starts the "taskkill" program. With

/IM "ExecutableName.exe"

as argument it will shut down the ExecutableName.exe. You may need to add a /F switch to make it force the program to shutdown (instead of just asking nicely).


This is just a addition to Anders J's answer...

On Windows 10 in System log I right clicked on Event Id 42 and added task (bat script basically) with taskkill command from my comment...

Attach Task To This Event...

  1. I've found this utility, but I haven't tried it.

  2. You can script it. How to make a computer sleep you can find here. How to kill a specific process you can find here. Just put both in one file with ".bat" as extension.

  • Well, I don't need to trigger sleep automatically. I need to "subscribe" to sleep event and be able to run the command then. Oct 3 '13 at 15:13
  • I would have suggested EventTriggers.exe (Win XP\2003, in newer versions there's an option in eventvwr.msc), but I don't know how it acts exactly and if Windows actually waits for the trigger to end before shutting down. The first option I've suggested seems to do (haven't tried myself, as I wrote) what you're asking for, and the second option gives you a manual option to that.
    – EliadTech
    Oct 6 '13 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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