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?
3 Answers
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).
-
11st link from Google - winaero.com/blog/kill-process-windows-10 e.g. SupperPutty asked for confirmation without /F, so
taskkill /IM SuperPutty.exe /F
– BetlistaMay 9, 2019 at 19:14
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...
-
1Well, 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, 2013 at 15:13
-
1I 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. Oct 6, 2013 at 5:18