use consistent context in installer (#333)

This commit is contained in:
Cyano Hao 2024-03-28 14:54:17 +08:00 committed by GitHub
parent e58adc94ff
commit 63b31ddda6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 97 additions and 101 deletions

View File

@ -40,7 +40,7 @@ InstType "Minimal";2
InstType "Safe";3 InstType "Safe";3
## Remember the installer language ## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM" !define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++" !define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
@ -77,14 +77,13 @@ Section "$(SectionMainName)" SectionMain
SetOutPath $INSTDIR SetOutPath $INSTDIR
SetRegView 64
; Allways create an uninstaller ; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe" WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files ; Write required files
@ -226,9 +225,7 @@ SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3 SectionIn 1 3
; always use all user start menu, normal users can delete these
SetShellVarContext all
StrCpy $0 $SMPROGRAMS ; start menu Programs folder StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)" CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
@ -238,9 +235,7 @@ SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3 SectionIn 1 3
; always use current user desktop, normal users can't delete all users' shortcuts
SetShellVarContext current
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd SectionEnd
@ -274,6 +269,8 @@ Function .onInit
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED} SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 32
FunctionEnd FunctionEnd
Function myGuiInit Function myGuiInit
@ -283,6 +280,7 @@ Function myGuiInit
Call UninstallExisting Call UninstallExisting
SetRegView 64 SetRegView 64
Call UninstallExisting Call UninstallExisting
SetRegView 32
FunctionEnd FunctionEnd
@ -291,7 +289,7 @@ Function BackupAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
;check if backup already exists ;check if backup already exists
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry ;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc StrCmp $1 "" 0 no_assoc
@ -300,13 +298,16 @@ Function BackupAssoc
StrCmp $1 "DevCpp$0" no_assoc StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc StrCmp $1 "" no_assoc
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc: no_assoc:
FunctionEnd FunctionEnd
Function un.onInit Function un.onInit
!insertmacro MUI_UNGETLANGUAGE !insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 32
FunctionEnd FunctionEnd
;restore file association ;restore file association
@ -314,7 +315,7 @@ Function un.RestoreAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0" DeleteRegKey HKCR "$0"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1" WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons Call un.RefreshShellIcons
@ -383,7 +384,7 @@ Function GetParent
FunctionEnd FunctionEnd
Function UninstallExisting Function UninstallExisting
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done StrCmp $R0 "" done
@ -418,15 +419,13 @@ Section "Uninstall"
; Remove uninstaller ; Remove uninstaller
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff, located in all users folder ; Remove start menu stuff
SetShellVarContext all
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk" Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)" RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff, located in current user folder ; Remove desktop stuff
SetShellVarContext current
Delete "$QUICKLAUNCH\$(MessageAppName).lnk" Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk" Delete "$DESKTOP\$(MessageAppName).lnk"
@ -471,8 +470,8 @@ Section "Uninstall"
Call un.DeleteDirIfEmpty Call un.DeleteDirIfEmpty
; Remove registry keys ; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKCU "Software\RedPanda-C++" DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
@ -480,4 +479,4 @@ Section "Uninstall"
RMDir /r "$APPDATA\RedPandaIDE" RMDir /r "$APPDATA\RedPandaIDE"
Done: Done:
SectionEnd SectionEnd

View File

@ -41,7 +41,7 @@ InstType "Minimal";2
InstType "Safe";3 InstType "Safe";3
## Remember the installer language ## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM" !define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++" !define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
@ -78,14 +78,13 @@ Section "$(SectionMainName)" SectionMain
SetOutPath $INSTDIR SetOutPath $INSTDIR
SetRegView 32
; Allways create an uninstaller ; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe" WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files ; Write required files
@ -234,9 +233,7 @@ SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3 SectionIn 1 3
; always use all user start menu, normal users can delete these
SetShellVarContext all
StrCpy $0 $SMPROGRAMS ; start menu Programs folder StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)" CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
@ -246,9 +243,7 @@ SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3 SectionIn 1 3
; always use current user desktop, normal users can't delete all users' shortcuts
SetShellVarContext current
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd SectionEnd
@ -283,6 +278,8 @@ Function .onInit
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED} SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 32
FunctionEnd FunctionEnd
Function myGuiInit Function myGuiInit
@ -290,6 +287,9 @@ Function myGuiInit
; uninstall existing ; uninstall existing
SetRegView 32 SetRegView 32
Call UninstallExisting Call UninstallExisting
SetRegView 64
Call UninstallExisting
SetRegView 32
FunctionEnd FunctionEnd
@ -298,7 +298,7 @@ Function BackupAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
;check if backup already exists ;check if backup already exists
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry ;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc StrCmp $1 "" 0 no_assoc
@ -307,13 +307,16 @@ Function BackupAssoc
StrCmp $1 "DevCpp$0" no_assoc StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc StrCmp $1 "" no_assoc
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc: no_assoc:
FunctionEnd FunctionEnd
Function un.onInit Function un.onInit
!insertmacro MUI_UNGETLANGUAGE !insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 32
FunctionEnd FunctionEnd
;restore file association ;restore file association
@ -321,7 +324,7 @@ Function un.RestoreAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0" DeleteRegKey HKCR "$0"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1" WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons Call un.RefreshShellIcons
@ -390,7 +393,7 @@ Function GetParent
FunctionEnd FunctionEnd
Function UninstallExisting Function UninstallExisting
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done StrCmp $R0 "" done
@ -425,15 +428,13 @@ Section "Uninstall"
; Remove uninstaller ; Remove uninstaller
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff, located in all users folder ; Remove start menu stuff
SetShellVarContext all
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk" Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)" RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff, located in current user folder ; Remove desktop stuff
SetShellVarContext current
Delete "$QUICKLAUNCH\$(MessageAppName).lnk" Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk" Delete "$DESKTOP\$(MessageAppName).lnk"
@ -479,8 +480,8 @@ Section "Uninstall"
Call un.DeleteDirIfEmpty Call un.DeleteDirIfEmpty
; Remove registry keys ; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKCU "Software\RedPanda-C++" DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
@ -488,4 +489,4 @@ Section "Uninstall"
RMDir /r "$APPDATA\RedPandaIDE" RMDir /r "$APPDATA\RedPandaIDE"
Done: Done:
SectionEnd SectionEnd

View File

@ -40,7 +40,7 @@ InstType "Minimal";2
InstType "Safe";3 InstType "Safe";3
## Remember the installer language ## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM" !define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++" !define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
@ -77,14 +77,13 @@ Section "$(SectionMainName)" SectionMain
SetOutPath $INSTDIR SetOutPath $INSTDIR
SetRegView 64
; Allways create an uninstaller ; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe" WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files ; Write required files
@ -226,9 +225,7 @@ SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3 SectionIn 1 3
; always use all user start menu, normal users can delete these
SetShellVarContext all
StrCpy $0 $SMPROGRAMS ; start menu Programs folder StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)" CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
@ -238,9 +235,7 @@ SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3 SectionIn 1 3
; always use current user desktop, normal users can't delete all users' shortcuts
SetShellVarContext current
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd SectionEnd
@ -274,6 +269,8 @@ Function .onInit
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED} SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 64
FunctionEnd FunctionEnd
Function myGuiInit Function myGuiInit
@ -291,7 +288,7 @@ Function BackupAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
;check if backup already exists ;check if backup already exists
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry ;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc StrCmp $1 "" 0 no_assoc
@ -300,13 +297,16 @@ Function BackupAssoc
StrCmp $1 "DevCpp$0" no_assoc StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc StrCmp $1 "" no_assoc
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc: no_assoc:
FunctionEnd FunctionEnd
Function un.onInit Function un.onInit
!insertmacro MUI_UNGETLANGUAGE !insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 64
FunctionEnd FunctionEnd
;restore file association ;restore file association
@ -314,7 +314,7 @@ Function un.RestoreAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0" DeleteRegKey HKCR "$0"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1" WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons Call un.RefreshShellIcons
@ -383,7 +383,7 @@ Function GetParent
FunctionEnd FunctionEnd
Function UninstallExisting Function UninstallExisting
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done StrCmp $R0 "" done
@ -418,15 +418,13 @@ Section "Uninstall"
; Remove uninstaller ; Remove uninstaller
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff, located in all users folder ; Remove start menu stuff
SetShellVarContext all
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk" Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)" RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff, located in current user folder ; Remove desktop stuff
SetShellVarContext current
Delete "$QUICKLAUNCH\$(MessageAppName).lnk" Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk" Delete "$DESKTOP\$(MessageAppName).lnk"
@ -471,8 +469,8 @@ Section "Uninstall"
Call un.DeleteDirIfEmpty Call un.DeleteDirIfEmpty
; Remove registry keys ; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKCU "Software\RedPanda-C++" DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
@ -480,4 +478,4 @@ Section "Uninstall"
RMDir /r "$APPDATA\RedPandaIDE" RMDir /r "$APPDATA\RedPandaIDE"
Done: Done:
SectionEnd SectionEnd

View File

@ -41,7 +41,7 @@ InstType "Minimal";2
InstType "Safe";3 InstType "Safe";3
## Remember the installer language ## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM" !define MUI_LANGDLL_REGISTRY_ROOT "ShCtx"
!define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++" !define MUI_LANGDLL_REGISTRY_KEY "Software\RedPanda-C++"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
@ -78,14 +78,13 @@ Section "$(SectionMainName)" SectionMain
SetOutPath $INSTDIR SetOutPath $INSTDIR
SetRegView 64
; Allways create an uninstaller ; Allways create an uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe" WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayName" "Redpanda-C++"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayVersion" "${DEVCPP_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "DisplayIcon" "$INSTDIR\RedPandaIDE.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "Publisher" "Roy Qu(royqh1979@gmail.com)"
; Write required files ; Write required files
@ -234,9 +233,7 @@ SubSection "$(SectionShortcutsName)" SectionShortcuts
Section "$(SectionMenuLaunchName)" SectionMenuLaunch Section "$(SectionMenuLaunchName)" SectionMenuLaunch
SectionIn 1 3 SectionIn 1 3
; always use all user start menu, normal users can delete these
SetShellVarContext all
StrCpy $0 $SMPROGRAMS ; start menu Programs folder StrCpy $0 $SMPROGRAMS ; start menu Programs folder
CreateDirectory "$0\$(MessageAppName)" CreateDirectory "$0\$(MessageAppName)"
CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$0\$(MessageAppName)\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
@ -246,9 +243,7 @@ SectionEnd
Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch Section "$(SectionDesktopLaunchName)" SectionDesktopLaunch
SectionIn 1 3 SectionIn 1 3
; always use current user desktop, normal users can't delete all users' shortcuts
SetShellVarContext current
CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe" CreateShortCut "$DESKTOP\$(MessageAppName).lnk" "$INSTDIR\RedPandaIDE.exe"
SectionEnd SectionEnd
@ -283,6 +278,8 @@ Function .onInit
IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file IfFileExists "$APPDATA\Dev-Cpp\devcpp.cfg" 0 +2 # deprecated config file
SectionSetFlags ${SectionConfig} ${SF_SELECTED} SectionSetFlags ${SectionConfig} ${SF_SELECTED}
SetShellVarContext all
SetRegView 64
FunctionEnd FunctionEnd
Function myGuiInit Function myGuiInit
@ -300,7 +297,7 @@ Function BackupAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
;check if backup already exists ;check if backup already exists
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
;don't backup if backup exists in registry ;don't backup if backup exists in registry
StrCmp $1 "" 0 no_assoc StrCmp $1 "" 0 no_assoc
@ -309,13 +306,16 @@ Function BackupAssoc
StrCmp $1 "DevCpp$0" no_assoc StrCmp $1 "DevCpp$0" no_assoc
StrCmp $1 "" no_assoc StrCmp $1 "" no_assoc
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1" WriteRegStr ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" "$1"
no_assoc: no_assoc:
FunctionEnd FunctionEnd
Function un.onInit Function un.onInit
!insertmacro MUI_UNGETLANGUAGE !insertmacro MUI_UNGETLANGUAGE
SetShellVarContext all
SetRegView 64
FunctionEnd FunctionEnd
;restore file association ;restore file association
@ -323,7 +323,7 @@ Function un.RestoreAssoc
;$0 is an extension - for example ".dev" ;$0 is an extension - for example ".dev"
DeleteRegKey HKCR "$0" DeleteRegKey HKCR "$0"
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0" ReadRegStr $1 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++\Backup" "$0"
StrCmp $1 "" no_backup StrCmp $1 "" no_backup
WriteRegStr HKCR "$0" "" "$1" WriteRegStr HKCR "$0" "" "$1"
Call un.RefreshShellIcons Call un.RefreshShellIcons
@ -392,7 +392,7 @@ Function GetParent
FunctionEnd FunctionEnd
Function UninstallExisting Function UninstallExisting
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString" ReadRegStr $R0 ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" "UninstallString"
StrCmp $R0 "" done StrCmp $R0 "" done
@ -427,15 +427,13 @@ Section "Uninstall"
; Remove uninstaller ; Remove uninstaller
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
; Remove start menu stuff, located in all users folder ; Remove start menu stuff
SetShellVarContext all
Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\$(MessageAppName).lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk" Delete "$SMPROGRAMS\$(MessageAppName)\License.lnk"
Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk" Delete "$SMPROGRAMS\$(MessageAppName)\Uninstall $(MessageAppName).lnk"
RMDir "$SMPROGRAMS\$(MessageAppName)" RMDir "$SMPROGRAMS\$(MessageAppName)"
; Remove desktop stuff, located in current user folder ; Remove desktop stuff
SetShellVarContext current
Delete "$QUICKLAUNCH\$(MessageAppName).lnk" Delete "$QUICKLAUNCH\$(MessageAppName).lnk"
Delete "$DESKTOP\$(MessageAppName).lnk" Delete "$DESKTOP\$(MessageAppName).lnk"
@ -480,8 +478,8 @@ Section "Uninstall"
Call un.DeleteDirIfEmpty Call un.DeleteDirIfEmpty
; Remove registry keys ; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++" DeleteRegKey ShCtx "Software\Microsoft\Windows\CurrentVersion\Uninstall\RedPanda-C++"
DeleteRegKey HKCU "Software\RedPanda-C++" DeleteRegKey ShCtx "Software\RedPanda-C++"
IfSilent +2 ; Don't ask when running in silent mode IfSilent +2 ; Don't ask when running in silent mode
MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done MessageBox MB_YESNO "$(MessageRemoveConfig)" IDNO Done
@ -489,4 +487,4 @@ Section "Uninstall"
RMDir /r "$APPDATA\RedPandaIDE" RMDir /r "$APPDATA\RedPandaIDE"
Done: Done:
SectionEnd SectionEnd