Skip to content
⌘ NSIS Forum Archive

Execute actions before reboot

64 posts

r2du-soft#
why when i run the loop function Check_Windows_Turned_OFF ,installer stop work and auto closed??

!include "x64.nsh"
!include "WndSubclass.nsh"
!include "WinMessages.nsh"

Function Check_Windows_Turned_OFF_Action
  ${If} $2 = ${WM_QUERYENDSESSION}
	WriteRegStr HKLM "SOFTWARE\1" "1" "OFF"
    Quit
  ${EndIf} 
FunctionEnd

Function Check_Windows_Turned_OFF
FindWindow $0 "#32770" "" $HWNDPARENT
${WndSubclass_Subclass} $0 Check_Windows_Turned_OFF_Action $5 $5
FunctionEnd

Section
BK:
Call Check_Windows_Turned_OFF
Goto BK
SectionEnd
TrifonovS#
I don't know if I make it right also, but if I want to avoid exit from the installer, I use the following code in the section:
; Dummy section
Section Dummy
ENDLESS_LOOP:
  Sleep 1000
  GoTo ENDLESS_LOOP
SectionEnd 
Your function Check_Windows_Turned_OFF_Action should be called automatically on every message that is received from the dialog.