Prevent Windows 7 Shutdown

I know that shutdown -a will abort Windows shutdown, but I need to know if there is somewhere where I can check if the shutdown is in progress.

Ideally, I need a small program:

  import os while True: shuttingDown = <shutdown variable to check> if shuttingDown: os.system("shutdown.exe -a") 
+4
source share
1 answer

To prevent Windows from shutting down when this happens, you can respond to the WM_QUERYENDSESSION message (you don’t know if you can do this easily with the Python win32 API, but it is simple in C). This may not prevent the closure of applications, as Windows sends WM_ENDSESSION to those who respond TRUE to the request message.

I think you'd rather want to prevent a temporary shutdown with shutdown.exe. I am sure that the program uses InitiateSystemShutdown to show a shutdown dialog, but there are no resources to intercept this call (at least I did not find any or know the Windows function that allows such a thing).

+1
source

Source: https://habr.com/ru/post/1302795/


All Articles