Old 19th July 2018, 13:09   #1
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 272
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?
r2du-soft is offline   Reply With Quote
Old 19th July 2018, 14:07   #2
TrifonovS
Senior Member
 
Join Date: Apr 2009
Location: Bulgaria
Posts: 190
Maybe you can find some useful information from my topic: http://forums.winamp.com/showthread.php?t=452693
TrifonovS is offline   Reply With Quote
Old 19th July 2018, 15:13   #3
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 272
Quote:
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 is offline   Reply With Quote
Old 19th July 2018, 19:27   #4
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 272
i found some examples:

SystemEvents.SessionEnding Event:
https://stackoverflow.com/questions/...down-or-logoff

SystemEvents.SessionEnding Event:
https://msdn.microsoft.com/en-us/lib...code-snippet-2

SystemEvents::SessionEnded Event:
https://msdn.microsoft.com/en-us/lib...sionended.aspx

also:
https://stackoverflow.com/questions/...a-winforms-app

also:
http://vbcity.com/forums/t/84431.aspx

But I do not know if this work is possible in nsis?!
r2du-soft is offline   Reply With Quote
Old 19th August 2018, 22:51   #5
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 272
Question

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!

HTML Code:
!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:
HTML Code:
StrCpy $Process "LogonUI.exe"
To
HTML Code:
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:
HTML Code:
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?
r2du-soft is offline   Reply With Quote
Old 20th August 2018, 17:18   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd August 2018, 21:26   #7
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 272
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
r2du-soft is offline   Reply With Quote
Old 22nd August 2018, 21:56   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
Is this actually a installer? If it is just an application, it might be better to write it in some other language, AutoIt maybe.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 23rd August 2018, 07:50   #9
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 272
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?
r2du-soft is offline   Reply With Quote
Old 23rd August 2018, 09:55   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
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).

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump