Python Forum

Full Version: Detecting windows shutdown event
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I probably have a tricky question here. I'd like to know if there's a way in python to detect (maybe using an infinite loop in a script run in background) if windows is shutting down, does anyone know how to do this?
other than blue screen of death?
Windows has a way of exploding.
Microsoft has a blog on this here: https://social.msdn.microsoft.com/Forums...rplanguage
I read the post you linked, but I don't need to interrupt shutdown process, I essentially want to execute a script when the shutdown button is pressed (not the physical one) and make sure that it execute correctly.
Quote:I'd like to know if there's a way in python to detect (maybe using an infinite loop in a script run in background) if windows is shutting dow
The first reply explains on URL I provided: 'how to intercept the shutdown command.'
you don't have to use the code verbatim, just use the 'Detect' part!!!
It looks like you could create a batch file to run your script on Windows shutdown.

Excecute code on Windows shutdown