|
30 | 30 |
|
31 | 31 | !include "MUI2.nsh" |
32 | 32 | !include "FileFunc.nsh" |
| 33 | + !include "x64.nsh" |
| 34 | + |
| 35 | + |
| 36 | +;-------------------------------- |
| 37 | +; UAC |
| 38 | + |
| 39 | + ; Request application privileges |
| 40 | + RequestExecutionLevel admin |
| 41 | + |
33 | 42 |
|
34 | 43 | ;-------------------------------- |
35 | 44 | ; General |
36 | 45 |
|
37 | | - !define INSTALLER_VERSION "0.0.1" |
| 46 | + !define INSTALLER_VERSION "0.0.1-alpha" |
38 | 47 | !define CMDER_VERSION "1.3.0" |
39 | 48 | !define APP_NAME "Cmder" |
40 | 49 | !define CMDER_DLURL "http://github.com/cmderdev/cmder/releases/download/v${CMDER_VERSION}/cmder_mini.zip" |
|
44 | 53 | BrandingText "${APP_INSTALLER_TEXT}" |
45 | 54 |
|
46 | 55 | ; Name / File |
47 | | - Name "${APP_NAME} v${CMDER_VERSION} Installer" |
| 56 | + Name "${APP_NAME} v${CMDER_VERSION}" |
48 | 57 | OutFile "cmder_inst_${INSTALLER_VERSION}.exe" |
49 | | - |
| 58 | + |
50 | 59 | ; Default Installation Folder |
51 | | - InstallDir $PROGRAMFILES\Cmder |
| 60 | + InstallDir $PROGRAMFILES\${APP_NAME} |
52 | 61 |
|
53 | | - ; Registry Key to check for directory |
| 62 | + ; Registry Set Up |
54 | 63 | !define REGLOC "Software\${APP_NAME}" |
55 | | - InstallDirRegKey HKLM "${REGLOC}" "InstallPath" |
56 | | - |
57 | | - ; Request application privileges for Windows Vista |
58 | | - RequestExecutionLevel admin |
| 64 | + !define REGROOT "HKLM" |
| 65 | + InstallDirRegKey ${REGROOT} "${REGLOC}" "InstallPath" |
59 | 66 |
|
60 | 67 | ; Uninstall Info |
61 | 68 | !define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" |
|
65 | 72 | ShowUninstDetails show |
66 | 73 | SpaceTexts none |
67 | 74 |
|
68 | | -;-------------------------------- |
69 | | -; Variables |
70 | | - |
71 | | - Var STARTMENUFOLDER |
72 | 75 |
|
73 | 76 | ;-------------------------------- |
74 | 77 | ; Interface Configuration |
75 | 78 |
|
76 | 79 | !define MUI_WELCOMEFINISHPAGE_BITMAP "img\cmder-side.bmp" |
77 | | - !define MUI_ABORTWARNING |
78 | 80 | !define MUI_ICON "img\cmder.ico" |
79 | 81 | !define MUI_UNICON "img\cmder.ico" |
80 | 82 |
|
81 | | - !define MUI_WELCOMEPAGE_TITLE "Welcome to the Cmder set up for Windows." |
| 83 | + !define MUI_WELCOMEPAGE_TITLE "Welcome to the ${APP_NAME} v${CMDER_VERSION} Installation Tool for Windows." |
| 84 | + !define MUI_WELCOMEPAGE_TITLE_3LINES |
82 | 85 | !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation the latest version of Cmder \ |
83 | 86 | for Windows.$\r$\n$\r$\nClick Next to continue." |
84 | 87 |
|
|
88 | 91 |
|
89 | 92 | !define MUI_COMPONENTSPAGE_NODESC |
90 | 93 |
|
91 | | - !define MUI_STARTMENUPAGE_DEFAULTFOLDER "${APP_NAME}" |
92 | | - |
93 | 94 | !define MUI_FINISHPAGE_NOAUTOCLOSE |
94 | 95 | !define MUI_FINISHPAGE_TITLE "Congratulations! You have installed Cmder." |
95 | | - !define MUI_FINISHPAGE_TEXT "You can now use Cmder. Start menu and/or desktop shortcuts have been created if you chose to do so." |
| 96 | + !define MUI_FINISHPAGE_TITLE_3LINES |
| 97 | + !define MUI_FINISHPAGE_TEXT "You can now use Cmder. Start menu and/or desktop shortcuts have been created \ |
| 98 | + if you chose to do so.$\r$\n$\r$\nPLEASE NOTE THAT YOU MUST EITHER RUN CMDER WITH THE CHECKBOX BELOW, \ |
| 99 | + OR RUN AS ADMINISTRATOR FOR THE FIRST TIME." |
96 | 100 | !define MUI_FINISHPAGE_RUN_TEXT "Run ${APP_NAME} v${CMDER_VERSION}" |
97 | 101 | !define MUI_FINISHPAGE_RUN "$INSTDIR\${APP_NAME}.exe" |
98 | | - !define MUI_FINISHPAGE_RUN_NOTCHECKED |
99 | 102 |
|
100 | | - !define MUI_STARTMENUPAGE_REGISTRY_ROOT |
| 103 | + !define MUI_FINISHPAGE_NOREBOOTSUPPORT |
| 104 | + |
| 105 | + !define MUI_ABORTWARNING |
| 106 | + !define MUI_ABORTWARNING_TEXT "Are you sure you want to cancel the installation of ${APP_NAME} v${CMDER_VERSION}?" |
| 107 | + !define MUI_ABORTWARNING_CANCEL_DEFAULT |
101 | 108 |
|
102 | | - !define MUI_UNCONFIRMPAGE_TEXT_TOP "All files will be removed from the install directory." |
| 109 | + !define MUI_UNCONFIRMPAGE_TEXT_TOP "This wizard will guide you through the uninstallation of ${APP_NAME} \ |
| 110 | + v${CMDER_VERSION}.$\r$\n$\r$\nBefore starting the uninstallation, please make sure that ${APP_NAME} \ |
| 111 | + is not running.$\r$\n$\r$\nClick Next to continue." |
| 112 | + !define MUI_UNFINISHPAGE_NOAUTOCLOSE |
103 | 113 |
|
104 | 114 | ;-------------------------------- |
105 | 115 | ; Pages |
106 | 116 |
|
| 117 | + ; Installer Pages |
| 118 | + !define MUI_PAGE_CUSTOMFUNCTION_PRE wel_pre |
107 | 119 | !insertmacro MUI_PAGE_WELCOME |
108 | 120 | !insertmacro MUI_PAGE_LICENSE LICENSE |
| 121 | + !define MUI_PAGE_CUSTOMFUNCTION_PRE dir_pre |
109 | 122 | !insertmacro MUI_PAGE_DIRECTORY |
110 | 123 | !insertmacro MUI_PAGE_COMPONENTS |
111 | | - !insertmacro MUI_PAGE_STARTMENU Application $STARTMENUFOLDER |
112 | 124 | !insertmacro MUI_PAGE_INSTFILES |
113 | 125 | !insertmacro MUI_PAGE_FINISH |
114 | 126 |
|
| 127 | + ; Uninstaller Pages |
115 | 128 | !insertmacro MUI_UNPAGE_CONFIRM |
| 129 | + !define MUI_PAGE_CUSTOMFUNCTION_PRE un.dir_pre |
116 | 130 | !insertmacro MUI_UNPAGE_INSTFILES |
| 131 | + !insertmacro MUI_UNPAGE_FINISH |
117 | 132 |
|
118 | 133 | ;-------------------------------- |
119 | 134 | ; Languages |
|
129 | 144 |
|
130 | 145 | Section "!Cmder ${CMDER_VERSION}" CmderInst |
131 | 146 | SectionIn 1 RO |
| 147 | + |
132 | 148 | SetOutPath "$INSTDIR" |
| 149 | + DetailPrint "Setting InstallDir: $INSTDIR" |
133 | 150 |
|
134 | 151 | ; ADD FILES |
135 | 152 | DetailPrint "Downloading latest Cmder (mini) from ${CMDER_DLURL}" |
|
140 | 157 | Abort |
141 | 158 |
|
142 | 159 | dlok: |
| 160 | + DetailPrint "Download OK" |
143 | 161 | !insertmacro ZIPDLL_EXTRACT "$TEMP/cmder_mini.zip" "$INSTDIR" "<ALL>" |
144 | 162 | Pop $0 |
| 163 | + DetailPrint "Unzipping Files" |
145 | 164 | StrCmp "$0" "success" unzipok |
146 | 165 | DetailPrint "Failed to Unzip Cmder Files" |
147 | 166 | Abort |
148 | 167 |
|
149 | 168 |
|
150 | 169 | unzipok: |
| 170 | + DetailPrint "Unzip OK" |
| 171 | + ; Delete Zip |
| 172 | + DetailPrint "Removing Temp File" |
| 173 | + delete $TEMP/cmder_mini.zip |
151 | 174 |
|
| 175 | + DetailPrint "Writing Registry Keys" |
152 | 176 | ; Store Installation Folder |
153 | | - WriteRegStr HKLM "${REGLOC}" "InstallPath" $INSTDIR |
154 | | - WriteRegStr HKLM "${REGLOC}" "Version" ${CMDER_VERSION} |
| 177 | + WriteRegStr ${REGROOT} "${REGLOC}" "InstallPath" $INSTDIR |
| 178 | + WriteRegStr ${REGROOT} "${REGLOC}" "Version" ${CMDER_VERSION} |
155 | 179 |
|
156 | | - ; Start Menu items |
157 | | - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
158 | | - CreateDirectory "$SMPROGRAMS\$STARTMENUFOLDER" |
159 | | - CreateShortCut "$SMPROGRAMS\$STARTMENUFOLDER\${APP_NAME}" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\icons\cmder.ico" |
160 | | - CreateShortCut "$SMPROGRAMS\$STARTMENUFOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe" |
161 | | - !insertmacro MUI_STARTMENU_WRITE_END |
| 180 | + ; Create Uninstaller |
| 181 | + WriteUninstaller "$INSTDIR\Uninstall.exe" |
162 | 182 |
|
163 | 183 | ; Write Uninstaller Registry Keys |
164 | | - WriteRegStr HKLM "${ARP}" "DisplayName" "Cmder" |
165 | | - WriteRegExpandStr HKLM "${ARP}" "UninstallString" "$INSTDIR\uninstall.exe" |
166 | | - WriteRegExpandStr HKLM "${ARP}" "QuietUninstallString" "$INSTDIR\uninstall.exe /S" |
167 | | - WriteRegExpandStr HKLM "${ARP}" "InstallLocation" "$INSTDIR" |
168 | | - WriteRegStr HKLM "${ARP}" "DisplayIcon" "$INSTDIR\icons\cmder.ico" |
169 | | - WriteRegStr HKLM "${ARP}" "DisplayVersion" "${CMDER_VERSION}" |
170 | | - WriteRegStr HKLM "${ARP}" "URLInfoAbout" "${CMDER_URL}" |
171 | | - WriteRegStr HKLM "${ARP}" "NoModify" 1 |
172 | | - WriteRegStr HKLM "${ARP}" "NoRepair" 1 |
| 184 | + WriteRegStr ${REGROOT} "${ARP}" "DisplayName" "Cmder" |
| 185 | + WriteRegExpandStr ${REGROOT} "${ARP}" "UninstallString" "$INSTDIR\uninstall.exe" |
| 186 | + WriteRegExpandStr ${REGROOT} "${ARP}" "QuietUninstallString" "$INSTDIR\uninstall.exe /S" |
| 187 | + WriteRegExpandStr ${REGROOT} "${ARP}" "InstallLocation" "$INSTDIR" |
| 188 | + WriteRegStr ${REGROOT} "${ARP}" "DisplayIcon" "$INSTDIR\icons\${APP_NAME}.ico" |
| 189 | + WriteRegStr ${REGROOT} "${ARP}" "DisplayVersion" "${CMDER_VERSION}" |
| 190 | + WriteRegStr ${REGROOT} "${ARP}" "URLInfoAbout" "${CMDER_URL}" |
| 191 | + WriteRegStr ${REGROOT} "${ARP}" "NoModify" 1 |
| 192 | + WriteRegStr ${REGROOT} "${ARP}" "NoRepair" 1 |
173 | 193 |
|
174 | 194 | ; Get Size |
175 | 195 | ${GetSize} "$INSTDIR" "/S=OK" $0 $1 $2 |
176 | | - IntFmt $0 "0x$08X" $0 |
177 | | - WriteRegDWORD HKLM "${ARP}" "EstimatedSize" "$0" |
178 | | - |
179 | | - ; Create Uninstaller |
180 | | - WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 196 | + IntFmt $0 "0x%08X" $0 |
| 197 | + WriteRegDWORD ${REGROOT} "${ARP}" "EstimatedSize" "$0" |
181 | 198 |
|
182 | 199 | SectionEnd |
183 | 200 |
|
184 | 201 | ; Shortcuts |
185 | 202 | SectionGroup /e "Shortcuts" |
186 | 203 | Section "Start Menu" |
187 | | - ; Start Menu items |
188 | | - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
189 | | - CreateDirectory "$SMPROGRAMS\$STARTMENUFOLDER" |
190 | | - CreateShortCut "$SMPROGRAMS\$STARTMENUFOLDER\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\icons\cmder.ico" |
191 | | - CreateShortCut "$SMPROGRAMS\$STARTMENUFOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe" |
192 | | - !insertmacro MUI_STARTMENU_WRITE_END |
| 204 | + DetailPrint "Writing StartMenu Shortcut" |
| 205 | + ; Start Menu item |
| 206 | + CreateShortCut "$SMPROGRAMS\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\icons\${APP_NAME}.ico" 0 |
| 207 | + |
193 | 208 | SectionEnd |
194 | 209 |
|
195 | 210 | Section /o "Create Desktop Icon" |
196 | 211 | ;Create Desktop Shortcut |
197 | | - CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" |
| 212 | + DetailPrint "Writing Desktop Shorcut" |
| 213 | + SetOutPath $INSTDIR |
| 214 | + SetShellVarContext all |
| 215 | + SetOverwrite on |
| 216 | + CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" "" "$INSTDIR\icons\${APP_NAME}.ico" 0 |
| 217 | + SetOverwrite off |
198 | 218 | SectionEnd |
199 | 219 | SectionGroupEnd |
200 | 220 |
|
|
203 | 223 |
|
204 | 224 | ; Open Cmder Here |
205 | 225 | Section 'Add "Open Cmder Here"' |
206 | | - |
| 226 | + DetailPrint "Adding Explorer Integrations" |
207 | 227 | WriteRegStr HKCR "Directory\Background\shell\${APP_NAME}" "" "Open Cmder Here" |
208 | 228 | WriteRegStr HKCR "Directory\Background\shell\${APP_NAME}" "Icon" "$INSTDIR\icons\cmder.ico" |
209 | 229 | WriteRegStr HKCR "Directory\Background\shell\${APP_NAME}\command" "" '"$INSTDIR\${APP_NAME}.exe" "%V"' |
210 | 230 |
|
211 | 231 | WriteRegStr HKCR "Directory\shell\${APP_NAME}" "" "Open Cmder Here" |
212 | | - WriteRegStr HkCR "Directory\shell\${APP_NAME}" "Icon" "$INSTDIR\icons\cmder.ico" |
| 232 | + WriteRegStr HKCR "Directory\shell\${APP_NAME}" "Icon" "$INSTDIR\icons\cmder.ico" |
213 | 233 | WriteRegStr HKCR "Directory\shell\${APP_NAME}\command" "" '"$INSTDIR\${APP_NAME}.exe" "%1"' |
214 | 234 |
|
215 | 235 | SectionEnd |
|
223 | 243 |
|
224 | 244 | Section "Uninstall" |
225 | 245 |
|
226 | | - ; Remove Start Menu Item |
227 | | - delete "$SMPROGRAMS\$STARTMENUFOLDER\${APP_NAME}.lnk" |
228 | | - delete "$SMPROGRAMS\$STARTMENUFOLDER\Uninstall.lnk" |
229 | | - rmDir "$SMPROGRAMS\$STARTMENUFOLDER" |
230 | | - |
| 246 | + ; Remove Start Menu Items |
| 247 | + SetShellVarContext all |
| 248 | + DetailPrint "Removing StartMenu Item" |
| 249 | + delete "$SMPROGRAMS\${APP_NAME}.lnk" |
| 250 | + |
231 | 251 | ; Remove Desktop Link |
| 252 | + DetailPrint "Removing Desktop Shortcut" |
232 | 253 | delete $DESKTOP\${APP_NAME}.lnk |
233 | 254 |
|
234 | 255 | ; Remove Files |
| 256 | + DetailPrint "Removing Files" |
235 | 257 | rmDir /r "$INSTDIR\bin" |
236 | 258 | rmDir /r "$INSTDIR\config" |
237 | 259 | rmDir /r "$INSTDIR\icons" |
|
247 | 269 | rmDir $INSTDIR |
248 | 270 |
|
249 | 271 | ; Remove Registry Keys |
250 | | - DeleteRegKey HKLM "${REGLOC}" |
| 272 | + DetailPrint "Removing Registry Keys" |
| 273 | + DeleteRegKey ${REGROOT} "${REGLOC}" |
251 | 274 | DeleteRegKey HKCR "Directory\Background\shell\${APP_NAME}" |
252 | 275 | DeleteRegKey HKCR "Directory\shell\${APP_NAME}" |
253 | | - DeleteRegKey HKLM "${ARP}" |
| 276 | + DeleteRegKey ${REGROOT} "${ARP}" |
254 | 277 |
|
255 | 278 | SectionEnd |
256 | 279 |
|
257 | 280 |
|
258 | 281 | ;-------------------------------- |
259 | 282 | ; Extra Functions |
| 283 | + |
260 | 284 | Function .onInit |
261 | 285 | InitPluginsDir |
262 | 286 | File "/oname=$PluginsDir\spltmp.bmp" "img\cmder-splash.bmp" |
|
269 | 293 |
|
270 | 294 | FunctionEnd |
271 | 295 |
|
| 296 | + |
| 297 | + Function wel_pre |
| 298 | + messagebox MB_OK|MB_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND "NOTE: Please remember to run Cmder \ |
| 299 | + from the final installation page OR run as administrator the first time." |
| 300 | + FunctionEnd |
| 301 | + |
| 302 | + |
| 303 | + Function dir_pre |
| 304 | + ; x64 Setup |
| 305 | + ${If} ${RunningX64} |
| 306 | + DetailPrint "Installer running on 64-bit host" |
| 307 | + |
| 308 | + ; Disable registry redirection |
| 309 | + SetRegView 64 |
| 310 | + |
| 311 | + ; Set Install Dir Root |
| 312 | + StrCpy $INSTDIR "$PROGRAMFILES64\${APP_NAME}" |
| 313 | + ${EndIf} |
| 314 | + FunctionEnd |
| 315 | + |
| 316 | + Function un.dir_pre |
| 317 | + ; x64 Setup |
| 318 | + ${If} ${RunningX64} |
| 319 | + DetailPrint "Installer running on 64-bit host" |
| 320 | + |
| 321 | + ; Disable registry redirection |
| 322 | + SetRegView 64 |
| 323 | + |
| 324 | + ; Set Install Dir Root |
| 325 | + StrCpy $INSTDIR "$PROGRAMFILES64\${APP_NAME}" |
| 326 | + ${EndIf} |
| 327 | + FunctionEnd |
| 328 | + |
| 329 | + |
272 | 330 | ; END NSIS Script |
0 commit comments