[20] | 1 | ; NSIS installer script for MAVA Logger X
|
---|
| 2 |
|
---|
| 3 | ;--------------------------------
|
---|
| 4 | ;Include Modern UI
|
---|
| 5 |
|
---|
| 6 | !include "MUI.nsh"
|
---|
[373] | 7 | !include "nsDialogs.nsh"
|
---|
| 8 | !include "TextFunc.nsh"
|
---|
[20] | 9 | !include "mlx-common.nsh"
|
---|
| 10 |
|
---|
| 11 | ;--------------------------------
|
---|
| 12 | ;General
|
---|
| 13 |
|
---|
[373] | 14 | Var ApplicationName
|
---|
| 15 |
|
---|
| 16 | Function .onInit
|
---|
| 17 | StrCpy $ApplicationName "Mava Logger X"
|
---|
| 18 | FunctionEnd
|
---|
| 19 |
|
---|
[20] | 20 | ;Name and file
|
---|
| 21 | Name "MAVA Logger X"
|
---|
| 22 | Caption "MAVA Logger X ${MLX_VERSION} Setup"
|
---|
| 23 | OutFile "MAVA Logger X-${MLX_VERSION}-Setup.exe"
|
---|
| 24 |
|
---|
| 25 | ;Default installation folder
|
---|
| 26 | InstallDir "$PROGRAMFILES\MAVA Logger X"
|
---|
| 27 |
|
---|
| 28 | ;Vista redirects $SMPROGRAMS to all users without this
|
---|
| 29 | RequestExecutionLevel admin
|
---|
| 30 |
|
---|
| 31 | ;--------------------------------
|
---|
| 32 | ;Variables
|
---|
| 33 |
|
---|
| 34 | Var MUI_TEMP
|
---|
| 35 | Var STARTMENU_FOLDER
|
---|
[373] | 36 | Var Variable
|
---|
| 37 | Var Secondary
|
---|
| 38 | Var Secondary_State
|
---|
| 39 | Var LinkName
|
---|
| 40 | Var Parameters
|
---|
[20] | 41 |
|
---|
| 42 | ;--------------------------------
|
---|
| 43 | ;Interface Settings
|
---|
| 44 |
|
---|
[28] | 45 | !define MUI_ICON "logo.ico"
|
---|
| 46 | !define MUI_UNICON "logo_uninst.ico"
|
---|
[20] | 47 | !define MUI_ABORTWARNING
|
---|
| 48 |
|
---|
| 49 | ;--------------------------------
|
---|
| 50 | ;Pages
|
---|
| 51 |
|
---|
[373] | 52 |
|
---|
[20] | 53 | !insertmacro MUI_PAGE_LICENSE "license.txt"
|
---|
[373] | 54 | Page custom optionsPage ;optionsPageLeave
|
---|
[20] | 55 | !insertmacro MUI_PAGE_COMPONENTS
|
---|
| 56 | !insertmacro MUI_PAGE_DIRECTORY
|
---|
| 57 |
|
---|
| 58 | ;Start Menu Folder Page Configuration
|
---|
[373] | 59 | ;!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
|
---|
| 60 | ;!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\MAVA Logger X"
|
---|
| 61 | ;!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
---|
| 62 |
|
---|
[20] | 63 | !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
---|
| 64 |
|
---|
| 65 | !insertmacro MUI_PAGE_INSTFILES
|
---|
[373] | 66 |
|
---|
[20] | 67 | !insertmacro MUI_UNPAGE_CONFIRM
|
---|
| 68 | !insertmacro MUI_UNPAGE_INSTFILES
|
---|
[373] | 69 |
|
---|
| 70 | Function optionsPage
|
---|
| 71 | !insertmacro MUI_HEADER_TEXT "Installation Options" "Choose the options for the installation"
|
---|
| 72 |
|
---|
| 73 | nsDialogs::Create 1018
|
---|
| 74 | Pop $Variable
|
---|
| 75 |
|
---|
| 76 | ${If} $Variable == error
|
---|
| 77 | Abort
|
---|
| 78 | ${Endif}
|
---|
| 79 |
|
---|
[376] | 80 | ${NSD_CreateLabel} 0 0 100% 32u "If you select the option below, the program will be installed in a way that it can be used besides another, already existing installation. Its default configuration will be such that it does not conflict with another logger running as a primary one. Normally, you should leave this unchecked."
|
---|
[373] | 81 | Pop $Variable
|
---|
| 82 |
|
---|
[376] | 83 | ${NSD_CreateCheckBox} 12 62 100% 12u "Install as a secondary copy"
|
---|
[373] | 84 | Pop $Secondary
|
---|
| 85 | ${NSD_SetState} $Secondary $Secondary_State
|
---|
| 86 | GetFunctionAddress $Variable onSecondaryClicked
|
---|
| 87 | nsDialogs::onClick $Secondary $Variable
|
---|
| 88 |
|
---|
| 89 | nsDialogs::Show
|
---|
| 90 | FunctionEnd
|
---|
| 91 |
|
---|
| 92 | Function onSecondaryClicked
|
---|
| 93 | Pop $Secondary
|
---|
| 94 | ${NSD_GetState} $Secondary $Secondary_State
|
---|
| 95 | ${If} $Secondary_State == ${BST_CHECKED}
|
---|
| 96 | StrCpy $INSTDIR "$PROGRAMFILES\MAVA Logger X (Secondary)"
|
---|
| 97 | StrCpy $STARTMENU_FOLDER "MAVA Logger X (Secondary)"
|
---|
| 98 | ${Else}
|
---|
| 99 | StrCpy $INSTDIR "$PROGRAMFILES\MAVA Logger X"
|
---|
| 100 | StrCpy $STARTMENU_FOLDER "MAVA Logger X"
|
---|
| 101 | ${EndIf}
|
---|
| 102 | FunctionEnd
|
---|
| 103 |
|
---|
[20] | 104 | ;--------------------------------
|
---|
| 105 | ;Languages
|
---|
[373] | 106 |
|
---|
[20] | 107 | !insertmacro MUI_LANGUAGE "English"
|
---|
| 108 |
|
---|
| 109 | ;--------------------------------
|
---|
| 110 | ;Installer Sections
|
---|
| 111 |
|
---|
| 112 | Section "MAVA Logger X" SecMLX
|
---|
| 113 |
|
---|
| 114 | SetOutPath "$INSTDIR"
|
---|
[373] | 115 |
|
---|
| 116 | ${If} $Secondary_State == ${BST_CHECKED}
|
---|
| 117 | StrCpy $LinkName "MAVA Logger X (Secondary)"
|
---|
| 118 | StrCpy $Parameters "secondary"
|
---|
| 119 | ${Else}
|
---|
| 120 | StrCpy $LinkName "MAVA Logger X"
|
---|
| 121 | StrCpy $Parameters ""
|
---|
| 122 | ${EndIf}
|
---|
| 123 |
|
---|
[20] | 124 | ;ADD YOUR OWN FILES HERE...
|
---|
| 125 | File /r dist\*.*
|
---|
| 126 |
|
---|
[373] | 127 | ;Create the uninstaller config file
|
---|
| 128 | ${ConfigWrite} "$INSTDIR\Uninstall.conf" "StartMenuFolder=" "$STARTMENU_FOLDER" $Variable
|
---|
| 129 | ${ConfigWrite} "$INSTDIR\Uninstall.conf" "LinkName=" "$LinkName" $Variable
|
---|
| 130 |
|
---|
[20] | 131 | ;Create uninstaller
|
---|
[373] | 132 |
|
---|
[20] | 133 | WriteUninstaller "$INSTDIR\Uninstall.exe"
|
---|
| 134 |
|
---|
| 135 | !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
---|
| 136 | ;Create shortcuts
|
---|
| 137 | CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
|
---|
[373] | 138 | CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe" "$Parameters"
|
---|
[20] | 139 | CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
---|
[373] | 140 | CreateShortCut "$DESKTOP\$LinkName.lnk" "$INSTDIR\runmlx.exe" "$Parameters"
|
---|
[20] | 141 | !insertmacro MUI_STARTMENU_WRITE_END
|
---|
| 142 | SectionEnd
|
---|
| 143 |
|
---|
| 144 | ;--------------------------------
|
---|
| 145 | ;Descriptions
|
---|
| 146 |
|
---|
| 147 | ;Language strings
|
---|
| 148 | LangString DESC_SecMLX ${LANG_ENGLISH} "MAVA Logger X."
|
---|
| 149 |
|
---|
| 150 | ;Assign language strings to sections
|
---|
| 151 | !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
---|
| 152 | !insertmacro MUI_DESCRIPTION_TEXT ${SecMLX} $(DESC_SecMLX)
|
---|
| 153 | !insertmacro MUI_FUNCTION_DESCRIPTION_END
|
---|
| 154 |
|
---|
| 155 | ;--------------------------------
|
---|
| 156 | ;Uninstaller Section
|
---|
| 157 |
|
---|
| 158 | Section "Uninstall"
|
---|
| 159 |
|
---|
[373] | 160 | ;Read the uninstaller config file
|
---|
| 161 | ${ConfigRead} "$INSTDIR\Uninstall.conf" "StartMenuFolder=" $MUI_TEMP
|
---|
| 162 | ${ConfigRead} "$INSTDIR\Uninstall.conf" "LinkName=" $LinkName
|
---|
| 163 |
|
---|
[20] | 164 | RMDir /r "$INSTDIR"
|
---|
| 165 |
|
---|
[373] | 166 | Delete "$DESKTOP\$LinkName.lnk"
|
---|
[20] | 167 | Delete "$SMPROGRAMS\$MUI_TEMP\MAVA Logger X.lnk"
|
---|
| 168 | Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
|
---|
[373] | 169 |
|
---|
[20] | 170 | ;Delete empty start menu parent diretories
|
---|
| 171 | StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
|
---|
[373] | 172 |
|
---|
[20] | 173 | startMenuDeleteLoop:
|
---|
| 174 | ClearErrors
|
---|
| 175 | RMDir $MUI_TEMP
|
---|
| 176 | GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
|
---|
[373] | 177 |
|
---|
[20] | 178 | IfErrors startMenuDeleteLoopDone
|
---|
[373] | 179 |
|
---|
[20] | 180 | StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
|
---|
| 181 | startMenuDeleteLoopDone:
|
---|
| 182 | SectionEnd
|
---|