Skip to content

Commit

Permalink
Fixed problems with the installer/uninstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonXLF committed Mar 18, 2023
1 parent 5a22a25 commit c89821f
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions NSIS.nsi
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
!define APP_NAME "Compactor"
!define APP_ICON "icon.ico"
!define LICENSE_FILE "LICENSE"
!define REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"

Name "${APP_NAME}"
BrandingText " "
OutFile "x64\${APP_NAME} Installer.exe"
Unicode True

!define PRODUCT "${APP_NAME}"
!define SHORT_PRODUCT_NAME "${APP_NAME}"
!define MULTIUSER_MUI
!define MULTIUSER_USE_PROGRAMFILES64
!define MULTIUSER_EXECUTIONLEVEL "Highest"
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_INSTDIR "${APP_NAME}"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${REG_KEY}"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "UninstallString"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REG_KEY}"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallLocation"
!define MULTIUSER_INSTALLMODE_INSTALL_REGISTRY_KEY "${APP_NAME}"
!define MULTIUSER_INSTALLMODE_UNINSTALL_REGISTRY_KEY "${APP_NAME}"
!define MULTIUSER_INSTALLMODE_ALLOW_ELEVATION
!define MULTIUSER_INSTALLMODE_DEFAULT_ALLUSERS

!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_ICON "${APP_ICON}"
!define MUI_UNICON "${APP_ICON}"
!define MULTIUSER_INSTALLMODE_INSTDIR "${APP_NAME}"
!define MUI_ICON "icon.ico"
!define MUI_UNICON "icon.ico"
!define MUI_FINISHPAGE_RUN "$INSTDIR\${APP_NAME}.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Launch ${APP_NAME}"

!include MUI2.nsh
!include MultiUser.nsh

!insertmacro MUI_PAGE_LICENSE "${LICENSE_FILE}"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
Expand All @@ -45,8 +39,6 @@ Unicode True
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

InstallDir "$PROGRAMFILES\${APP_NAME}"

Function .onInit
!insertmacro MULTIUSER_INIT
FunctionEnd
Expand All @@ -62,9 +54,10 @@ Section "${APP_NAME}" S1
WriteUninstaller "$INSTDIR\${APP_NAME} Uninstaller.exe"
WriteRegStr SHCTX "${REG_KEY}" "DisplayName" "${APP_NAME}"
WriteRegStr SHCTX "${REG_KEY}" "InstallLocation" "$INSTDIR"
WriteRegStr SHCTX "${REG_KEY}" "Publisher" "Brandon Fowler"
WriteRegDWORD SHCTX "${REG_KEY}" "NoModify" "1"
WriteRegDWORD SHCTX "${REG_KEY}" "NoRepair" "1"
WriteRegStr SHCTX "${REG_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr SHCTX "${REG_KEY}" "UninstallString" '"$INSTDIR\${APP_NAME} Uninstaller.exe"'
WriteRegStr SHCTX "${REG_KEY}" "DisplayIcon" "$INSTDIR\${APP_NAME}.exe"
SectionEnd

Expand All @@ -81,18 +74,16 @@ Section "Run On Startup" S4
SectionEnd

Section "Uninstall"
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\${APP_NAME}.exe"
RMDir /r /REBOOTOK $INSTDIR
Delete "$SMPROGRAMS\${APP_NAME}.lnk"
Delete "$SMSTARTUP\${APP_NAME}.lnk"
Delete "$DESKTOP\${APP_NAME}.lnk"
RMDir $INSTDIR
DeleteRegKey SHCTX "${REG_KEY}"
DeleteRegKey HKCU "Software\Compactor"
SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${S1} "Install ${APP_NAME} and its core file(s)"
!insertmacro MUI_DESCRIPTION_TEXT ${S4} "Run ${APP_NAME} on startup"
!insertmacro MUI_DESCRIPTION_TEXT ${S2} "Add a shortcut to ${APP_NAME} to the Start Menu"
!insertmacro MUI_DESCRIPTION_TEXT ${S3} "Add a shortcut to ${APP_NAME} to the Desktop folder"
!insertmacro MUI_DESCRIPTION_TEXT ${S4} "Run ${APP_NAME} on startup"
!insertmacro MUI_FUNCTION_DESCRIPTION_END

0 comments on commit c89821f

Please sign in to comment.