Check whether system requires restart or not: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.) |
m (Updated author links.) |
||
Line 1: | Line 1: | ||
{|align=right | |||
|<small>Author: [[{{ns:2}}:aman_ansari|aman_ansari]] ([[{{ns:3}}:aman_ansari|talk]], [[{{ns:-1}}:Contributions/aman_ansari|contrib]])</small> | |||
|} | |||
<br style="clear:both;"> | |||
== Description == | == Description == | ||
Using this function you can determine whether your system requires a restart or not. This can be useful when you are running external setup applications or want to check whether previously installers applications require a restart. | Using this function you can determine whether your system requires a restart or not. This can be useful when you are running external setup applications or want to check whether previously installers applications require a restart. | ||
Line 39: | Line 43: | ||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
Revision as of 23:14, 29 April 2005
Author: aman_ansari (talk, contrib) |
Description
Using this function you can determine whether your system requires a restart or not. This can be useful when you are running external setup applications or want to check whether previously installers applications require a restart.
To check whether your own installer requires a restart (when using /REBOOTOK parameters), use IfRebootFlag (see documentation).
Usage
Push $R1 Call RestartRequired Exch $R1 StrCmp $R1 "1" RestartRequired RestartNotRequired
The Function
Function RestartRequired Exch $R1 ;Original Variable Push $R2 Push $R3 ;Counter Variable StrCpy $R1 "0" 1 ;initialize variable with 0 StrCpy $R3 "0" 0 ;Counter Variable ;First Check Current User RunOnce Key EnumRegValue $R2 HKCU "Software\Microsoft\Windows\CurrentVersion\RunOnce" $R3 StrCmp $R2 "" 0 FoundRestart ;Next Check Local Machine Key EnumRegValue $R2 HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" $R3 StrCmp $R2 "" ExitFunc 0 FoundRestart: StrCpy $R1 "1" 1 ExitFunc: Pop $R2 Pop $R3 Exch $R1 FunctionEnd