mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 14:53:01 +02:00
use the UAC plugin to elevate uninstaller
This commit is contained in:
parent
0a0b152f97
commit
6bccdc81b4
1 changed files with 30 additions and 4 deletions
|
@ -30,8 +30,10 @@
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
;General
|
;General
|
||||||
|
|
||||||
!ifdef INNER
|
!ifdef INNER
|
||||||
|
; leverage the UAC NSIS plugin to promote uninstaller to elevated privileges
|
||||||
|
!include UAC.nsh
|
||||||
|
|
||||||
!echo "Inner invocation" ; just to see what's going on
|
!echo "Inner invocation" ; just to see what's going on
|
||||||
|
|
||||||
; Require user only for temp installer
|
; Require user only for temp installer
|
||||||
|
@ -62,7 +64,7 @@
|
||||||
; The Inner invocation has written an uninstaller binary for us.
|
; The Inner invocation has written an uninstaller binary for us.
|
||||||
; We need to sign it if it's a production or PR build.
|
; We need to sign it if it's a production or PR build.
|
||||||
!if @PRODUCTION_BUILD@ == 1
|
!if @PRODUCTION_BUILD@ == 1
|
||||||
!system '"@SIGNTOOL_EXECUTABLE@" sign /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com /td SHA256 $%TEMP%\uninstaller.exe' = 0
|
!system '"@SIGNTOOL_EXECUTABLE@" sign /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com /td SHA256 $%TEMP%\Uninstall.exe' = 0
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
; Good. Now we can carry on writing the real installer.
|
; Good. Now we can carry on writing the real installer.
|
||||||
|
@ -685,7 +687,7 @@ Section "-Core installation"
|
||||||
;Package the signed uninstaller produced by the inner loop
|
;Package the signed uninstaller produced by the inner loop
|
||||||
!ifndef INNER
|
!ifndef INNER
|
||||||
; this packages the signed uninstaller
|
; this packages the signed uninstaller
|
||||||
File $%TEMP%\uninstaller.exe
|
File $%TEMP%\Uninstaller.exe
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
Push "DisplayName"
|
Push "DisplayName"
|
||||||
|
@ -928,6 +930,29 @@ FunctionEnd
|
||||||
; determine admin versus local install
|
; determine admin versus local install
|
||||||
Function un.onInit
|
Function un.onInit
|
||||||
|
|
||||||
|
; attempt to elevate the uninstaller to admin status
|
||||||
|
uac_tryagain:
|
||||||
|
!insertmacro UAC_RunElevated
|
||||||
|
${Switch} $0
|
||||||
|
${Case} 0
|
||||||
|
${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
|
||||||
|
${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
|
||||||
|
${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
|
||||||
|
MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "The uninstaller requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
|
||||||
|
${EndIf}
|
||||||
|
;fall-through and die
|
||||||
|
|
||||||
|
${Case} 1223
|
||||||
|
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "The uninstaller requires admin privileges, aborting!"
|
||||||
|
Quit
|
||||||
|
${Case} 1062
|
||||||
|
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
|
||||||
|
Quit
|
||||||
|
${Default}
|
||||||
|
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0"
|
||||||
|
Quit
|
||||||
|
${EndSwitch}
|
||||||
|
|
||||||
ClearErrors
|
ClearErrors
|
||||||
UserInfo::GetName
|
UserInfo::GetName
|
||||||
IfErrors noLM
|
IfErrors noLM
|
||||||
|
@ -994,6 +1019,7 @@ FunctionEnd
|
||||||
|
|
||||||
!ifdef INNER
|
!ifdef INNER
|
||||||
Section "Uninstall"
|
Section "Uninstall"
|
||||||
|
|
||||||
ReadRegStr $START_MENU SHCTX \
|
ReadRegStr $START_MENU SHCTX \
|
||||||
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
|
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
|
||||||
;MessageBox MB_OK "Start menu is in: $START_MENU"
|
;MessageBox MB_OK "Start menu is in: $START_MENU"
|
||||||
|
@ -1107,7 +1133,7 @@ Function .onInit
|
||||||
; the installer. This is better than processing a command line option as it means
|
; the installer. This is better than processing a command line option as it means
|
||||||
; this entire code path is not present in the final (real) installer.
|
; this entire code path is not present in the final (real) installer.
|
||||||
|
|
||||||
WriteUninstaller "$%TEMP%\uninstaller.exe"
|
WriteUninstaller "$%TEMP%\Uninstall.exe"
|
||||||
|
|
||||||
; just bail out quickly when running the "inner" installer
|
; just bail out quickly when running the "inner" installer
|
||||||
Quit
|
Quit
|
||||||
|
|
Loading…
Reference in a new issue