Skip to content
⌘ NSIS Forum Archive

check windows want restart or shutdown

10 posts

r2du-soft#

check windows want restart or shutdown

how can check windows now want restart before installer closed by windows?
if windows restart and shutdown have flag?
i most save many values to registry before windows restart or shutdown...
Or moments before
Windows startup and shutdown
is Moments before windows restart or shutdown can recognize it?

before restart and shutdown:
witch process start OR witch process closed?
what changes are made to the registry?
which flag is changing and how it is accessed that flag?
TrifonovS#
Maybe you can find some useful information from my topic: http://forums.winamp.com/showthread.php?t=452693
r2du-soft#
Originally Posted by TrifonovS View Post
Maybe you can find some useful information from my topic: http://forums.winamp.com/showthread.php?t=452693
hi
thanks,i studied that topic
i try thats codes but i cant use thats in a loop and installer Automatically ends...
i most use that in loop to check windows want turned on of off or restart..
r2du-soft#
i found some examples:

SystemEvents.SessionEnding Event:


SystemEvents.SessionEnding Event:


SystemEvents::SessionEnded Event:


also:


also:
vbCity is a community of VB and .NET developers joined together with a common goal: to learn, teach, and have fun programming. Developers from all over the world come together to share knowledge, source code, and tutorials for free to help their fellow programmers - Professional Developers, Hobbyists and Students alike. (http://vbCity.com)


But I do not know if this work is possible in nsis?!
r2du-soft#
i found a way to save values in registry just before: Logoff,Restart,ShutDown and others...
Just before Logoff,Restart,ShutDown and others windows run LogonUI.exe process!

!include x64.nsh
Var Process

Section Section
${IF} ${RunningX64}
	SetRegView 64
${ELSE}
	SetRegView 32
${EndIF}

	GetFunctionAddress $0 ShutDown_Checker
    ThreadTimer::Start 1 0 $0

SectionEnd

Function ShutDown_Checker
	Try:
	StrCpy $Process "LogonUI.exe"
	LockedList::FindProcess "$Process"
	Pop $R0
	;MessageBox MB_OK "$R0"
	${If} $R0 S!= ""
		WriteRegStr HKLM "SOFTWARE\1" "Windows Status" "Windows Now Want (Logoff,Restart,ShutDown)"
		ThreadTimer::Stop
		Quit
	${ELSE}
		Goto Try
	${EndIf}
FunctionEnd

but i have a problem!
if change:
StrCpy $Process "LogonUI.exe"
To
StrCpy $Process "notepad.exe"
after run installer,run the notepad.exe
installer write the value in registry but QUIT not work and installer not closed!
i think problem was from:
ThreadTimer::Stop
Quit
I tried different ways but after saving value in the registry,installer not QUIT!!!

where is the problem from?
What is the problem solving method?
Anders#
LogonUI.exe did not exist before XP. It might be optional in XP/2003, I don't remember (might not be used when using the classic logon screen). Using a 1 ms interval is not nice, try something larger.

ThreadTimer runs the callback function in a different thread and Quit might not support that. You can try to send/post a WM_CLOSE or WM_COMMAND (click close/next) message after Quit.
r2du-soft#
i remove Quit and use from WM_CLOSE but thats notwork again!
also i need use loop for check windows is restart or .... , i cant use the WndSubclass_Subclass because when i use WndSubclass_Subclass installer crashed and closed....
i need a another way....
i need to help
Anders#
Is this actually a installer? If it is just an application, it might be better to write it in some other language, AutoIt maybe.
r2du-soft#
No
This is part of a software application that is written entirely with NSIS
In fact, I do not want to attach to the software and use other software to do this
I want this work to be done with nsis
But I do not have the information and the ability to do this

WndSubclass_Subclass Is it okay to do this?
Why in the loop software crashed?

WndSubclass_Subclass how it works?
How is that Rewrite WndSubclass_Subclass with system::call method?
Anders#
You cannot rewrite it with System::Call.

The problem is threads, Sections run in a different thread and NSIS scripts are not designed to run on multiple threads at the same time. It might be possible if you create window in a section and then subclass that (assuming you never leave the instfiles page).