| 1 |
;; ============================================================ |
| 2 |
; |
| 3 |
; This file is a part of digiKam project |
| 4 |
; https://www.digikam.org |
| 5 |
; |
| 6 |
; Date : 2010-11-08 |
| 7 |
; Description : Functions to check if reboot is required. |
| 8 |
; Note: NSIS >= 3 is required to be compatible with Windows 10. |
| 9 |
; |
| 10 |
; SPDX-FileCopyrightText: 2010-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 11 |
; |
| 12 |
; SPDX-License-Identifier: GPL-2.0-or-later |
| 13 |
; |
| 14 |
; ============================================================ ;; |
| 15 |
|
| 16 |
!ifndef REBOOT_REQUIRED_INCLUDED |
| 17 |
!define REBOOT_REQUIRED_INCLUDED |
| 18 |
|
| 19 |
Function DirectoryLeave |
| 20 |
|
| 21 |
Call NotifyIfRebootRequired |
| 22 |
|
| 23 |
FunctionEnd |
| 24 |
|
| 25 |
;------------------------------------------- |
| 26 |
|
| 27 |
Function NotifyIfRebootRequired |
| 28 |
|
| 29 |
Call IsRebootRequired |
| 30 |
Exch $0 |
| 31 |
|
| 32 |
${If} $0 == 1 |
| 33 |
|
| 34 |
;TODO: consider adding a RunOnce entry for the installer to HKCU instead of telling the user they need to run the installer |
| 35 |
;themselves (can't add to HKLM because basic user wouldn't have access, only admins do). |
| 36 |
;this would require using the UAC plugin to handle elevation by starting as a normal user, elevating, and then dropping back to normal when writing to HKCU |
| 37 |
;TODO: need to internationalize string (see VLC / clementine / etc) |
| 38 |
|
| 39 |
MessageBox MB_YESNO|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "You must reboot to complete uninstallation of a previous install of ${MY_PRODUCT} before ${MY_PRODUCT} ${VERSION} can be installed.$\r$\n$\r$\n\ |
| 40 |
Would you like to reboot now?$\r$\n$\r$\n\ |
| 41 |
(You will have to run the installer again after reboot to continue setup)" /SD IDNO IDNO noInstall |
| 42 |
Reboot |
| 43 |
|
| 44 |
${Else} |
| 45 |
|
| 46 |
Goto done |
| 47 |
|
| 48 |
${EndIf} |
| 49 |
|
| 50 |
noInstall: |
| 51 |
Abort |
| 52 |
|
| 53 |
done: |
| 54 |
Pop $0 |
| 55 |
|
| 56 |
FunctionEnd |
| 57 |
|
| 58 |
Function IsRebootRequired |
| 59 |
|
| 60 |
Push $0 |
| 61 |
Push $1 |
| 62 |
Push $2 |
| 63 |
Push $3 |
| 64 |
|
| 65 |
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager" "PendingFileRenameOperations" |
| 66 |
|
| 67 |
${If} $0 != "" |
| 68 |
|
| 69 |
StrLen $2 "$INSTDIR" |
| 70 |
${StrStr} $1 "$0" "$INSTDIR" |
| 71 |
StrCpy $3 $1 $2 |
| 72 |
${AndIf} $3 == "$INSTDIR" |
| 73 |
StrCpy $0 1 |
| 74 |
|
| 75 |
${Else} |
| 76 |
|
| 77 |
StrCpy $0 0 |
| 78 |
|
| 79 |
${EndIf} |
| 80 |
|
| 81 |
Pop $3 |
| 82 |
Pop $2 |
| 83 |
Pop $1 |
| 84 |
Exch $0 |
| 85 |
|
| 86 |
FunctionEnd |
| 87 |
|
| 88 |
!endif ;REBOOT_REQUIRED_INCLUDED |