| 1 |
;=============================================== |
| 2 |
; Requires following !defines in the calling *.nsi file |
| 3 |
; Examples: |
| 4 |
; REGISTRYNAME "TheHesslingEditor" |
| 5 |
; LONGNAME "The Hessling Editor" |
| 6 |
; SHORTNAME "THE" |
| 7 |
; KEYFILE "the.exe" |
| 8 |
; Name of key installed file in $INSTALLDIR |
| 9 |
; ARCH "w64" |
| 10 |
; 32bit (w32) or 64bit (w64) package architecture |
| 11 |
;=============================================== |
| 12 |
; |
| 13 |
; |
| 14 |
; set Registry view |
| 15 |
!if ${ARCH} == "w64" |
| 16 |
SetRegView 64 |
| 17 |
!else |
| 18 |
SetRegView 32 |
| 19 |
!endif |
| 20 |
|
| 21 |
UninstallDefault: |
| 22 |
; |
| 23 |
; Uninstall previous version if present |
| 24 |
; |
| 25 |
ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGISTRYNAME}" "UninstallString" |
| 26 |
StrCmp $R1 "" NoUninstall |
| 27 |
; |
| 28 |
; ask the user to run the uninstaller |
| 29 |
; |
| 30 |
ReadRegStr $R2 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGISTRYNAME}" "UnInstallLocation" |
| 31 |
StrCmp $R2 "" NoUninstallLocation |
| 32 |
Goto StartUninstall |
| 33 |
NoUninstallLocation: |
| 34 |
StrCpy $R2 $INSTDIR |
| 35 |
StartUninstall: |
| 36 |
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_TOPMOST "A version of ${LONGNAME} is currently installed.$\nIt is recommended that it be uninstalled before proceeding.$\nUninstall previous version?" /SD IDYES IDNO NoUninstall IDCANCEL DoAbort |
| 37 |
HideWindow |
| 38 |
ClearErrors |
| 39 |
ExecWait '$R1 _?=$R2' |
| 40 |
IfErrors no_remove_uninstaller |
| 41 |
IfFileExists "$INSTDIR\${KEYFILE}" no_remove_uninstaller |
| 42 |
RMDir /r "$R2" |
| 43 |
no_remove_uninstaller: |
| 44 |
BringToFront |
| 45 |
|
| 46 |
Goto NoUninstall |
| 47 |
DoAbort: |
| 48 |
Abort |
| 49 |
NoUninstall: |
| 50 |
; |
| 51 |
; Install as All Users if an admin |
| 52 |
; |
| 53 |
Call IsUserAdmin |
| 54 |
Pop $IsAdminUser |
| 55 |
StrCmp $IsAdminUser "false" DefaultUser |
| 56 |
SetShellVarContext all |
| 57 |
DefaultUser: |