Skip to content
⌘ NSIS Forum Archive

Preventing Windows restart during SILENT install

3 posts

orhuidobro#

Preventing Windows restart during SILENT install

Hello,
I read that an NSIS installer will prevent a Windows restart to happen while the script is running, returning FALSE to WM_QUERYENDSESSION. But I wasn't able to find what happens when the installer runs in SILENT mode.
Does anybody know certainly what happens if a reboot is launch (by external causes) while a SILENT install is running?
If the reboot isn't prevented, is there some way to get that?

Thank you.
Afrow UK#
It will not block a reboot because there is no window to handle WM_QUERYENDSESSION. If you need to do this you can create a hidden window which handles WM_QUERYENDSESSION. It would need to be in a plug-in.

Edit: This could be a useful plug-in so I might write it at some point. Additional features could be to use the ShutdownBlockReasonCreate/ShutdownBlockReasonDestroy APIs on Windows Vista+ and to add a function to allow a shutdown/reboot (I think I already wrote a plug-in for this bit but it is very old).

Stu
LoRd_MuldeR#
Not quite sure, but Console and Service applications can receive a WM_QUERYENDSESSION notification trough a handler routine registered via SetConsoleCtrlHandler(). Could it work with applications that don't actually have a console attached? 😕