Python Forum
Detecting windows shutdown event
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting windows shutdown event
#1
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?
Reply
#2
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
Reply
#3
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.
Reply
#4
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!!!
Reply
#5
It looks like you could create a batch file to run your script on Windows shutdown.

Excecute code on Windows shutdown
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb shutdown host from docker container cosmin1805 0 946 Nov-27-2022, 06:34 PM
Last Post: cosmin1805
  Os.system("shutdown"); command not found cosmin1805 4 1,673 Nov-13-2022, 02:07 PM
Last Post: cosmin1805
  iterating and detecting the last Skaperen 3 1,066 Oct-01-2022, 05:23 AM
Last Post: Gribouillis
  Detecting float or int in a string Clunk_Head 15 4,427 May-26-2022, 11:39 PM
Last Post: Pedroski55
  module detecting if imported vs not Skaperen 1 1,662 Nov-19-2021, 07:43 AM
Last Post: Yoriz
  detecting a generstor passed to a funtion Skaperen 9 3,566 Sep-23-2021, 01:29 AM
Last Post: Skaperen
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 1,999 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 2,255 May-18-2021, 06:31 AM
Last Post: Skaperen
  Detecting power plug Narayan 2 2,699 Aug-01-2020, 04:29 AM
Last Post: bowlofred
  Detecting USB Device Insertion on Windows 10 Atalanttore 0 2,372 Jan-17-2020, 02:46 PM
Last Post: Atalanttore

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020