| 1 |
; CPack install script designed for a nmake build |
| 2 |
|
| 3 |
;-------------------------------- |
| 4 |
; You must define these values |
| 5 |
|
| 6 |
!define VERSION "@CPACK_PACKAGE_VERSION@" |
| 7 |
!define PATCH "@CPACK_PACKAGE_VERSION_PATCH@" |
| 8 |
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" |
| 9 |
|
| 10 |
;-------------------------------- |
| 11 |
;Variables |
| 12 |
|
| 13 |
Var MUI_TEMP |
| 14 |
Var STARTMENU_FOLDER |
| 15 |
Var SV_ALLUSERS |
| 16 |
Var START_MENU |
| 17 |
Var DO_NOT_ADD_TO_PATH |
| 18 |
Var ADD_TO_PATH_ALL_USERS |
| 19 |
Var ADD_TO_PATH_CURRENT_USER |
| 20 |
Var INSTALL_DESKTOP |
| 21 |
Var IS_DEFAULT_INSTALLDIR |
| 22 |
;-------------------------------- |
| 23 |
;Include Modern UI |
| 24 |
|
| 25 |
!include "MUI.nsh" |
| 26 |
|
| 27 |
;Default installation folder |
| 28 |
InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" |
| 29 |
|
| 30 |
;-------------------------------- |
| 31 |
;General |
| 32 |
|
| 33 |
;Name and file |
| 34 |
Name "@CPACK_NSIS_PACKAGE_NAME@" |
| 35 |
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" |
| 36 |
|
| 37 |
;Set compression |
| 38 |
SetCompressor @CPACK_NSIS_COMPRESSOR@ |
| 39 |
|
| 40 |
@CPACK_NSIS_DEFINES@ |
| 41 |
|
| 42 |
!include Sections.nsh |
| 43 |
|
| 44 |
;--- Component support macros: --- |
| 45 |
; The code for the add/remove functionality is from: |
| 46 |
; http://nsis.sourceforge.net/Add/Remove_Functionality |
| 47 |
; It has been modified slightly and extended to provide |
| 48 |
; inter-component dependencies. |
| 49 |
Var AR_SecFlags |
| 50 |
Var AR_RegFlags |
| 51 |
@CPACK_NSIS_SECTION_SELECTED_VARS@ |
| 52 |
|
| 53 |
; Loads the "selected" flag for the section named SecName into the |
| 54 |
; variable VarName. |
| 55 |
!macro LoadSectionSelectedIntoVar SecName VarName |
| 56 |
SectionGetFlags ${${SecName}} $${VarName} |
| 57 |
IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits |
| 58 |
!macroend |
| 59 |
|
| 60 |
; Loads the value of a variable... can we get around this? |
| 61 |
!macro LoadVar VarName |
| 62 |
IntOp $R0 0 + $${VarName} |
| 63 |
!macroend |
| 64 |
|
| 65 |
; Sets the value of a variable |
| 66 |
!macro StoreVar VarName IntValue |
| 67 |
IntOp $${VarName} 0 + ${IntValue} |
| 68 |
!macroend |
| 69 |
|
| 70 |
!macro InitSection SecName |
| 71 |
; This macro reads component installed flag from the registry and |
| 72 |
;changes checked state of the section on the components page. |
| 73 |
;Input: section index constant name specified in Section command. |
| 74 |
|
| 75 |
ClearErrors |
| 76 |
;Reading component status from registry |
| 77 |
ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed" |
| 78 |
IfErrors "default_${SecName}" |
| 79 |
;Status will stay default if registry value not found |
| 80 |
;(component was never installed) |
| 81 |
IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits |
| 82 |
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags |
| 83 |
IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off |
| 84 |
IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit |
| 85 |
|
| 86 |
; Note whether this component was installed before |
| 87 |
!insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags |
| 88 |
IntOp $R0 $AR_RegFlags & $AR_RegFlags |
| 89 |
|
| 90 |
;Writing modified flags |
| 91 |
SectionSetFlags ${${SecName}} $AR_SecFlags |
| 92 |
|
| 93 |
"default_${SecName}:" |
| 94 |
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected |
| 95 |
!macroend |
| 96 |
|
| 97 |
!macro FinishSection SecName |
| 98 |
; This macro reads section flag set by user and removes the section |
| 99 |
;if it is not selected. |
| 100 |
;Then it writes component installed flag to registry |
| 101 |
;Input: section index constant name specified in Section command. |
| 102 |
|
| 103 |
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags |
| 104 |
;Checking lowest bit: |
| 105 |
IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED} |
| 106 |
IntCmp $AR_SecFlags 1 "leave_${SecName}" |
| 107 |
;Section is not selected: |
| 108 |
;Calling Section uninstall macro and writing zero installed flag |
| 109 |
!insertmacro "Remove_${${SecName}}" |
| 110 |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ |
| 111 |
"Installed" 0 |
| 112 |
Goto "exit_${SecName}" |
| 113 |
|
| 114 |
"leave_${SecName}:" |
| 115 |
;Section is selected: |
| 116 |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ |
| 117 |
"Installed" 1 |
| 118 |
|
| 119 |
"exit_${SecName}:" |
| 120 |
!macroend |
| 121 |
|
| 122 |
!macro RemoveSection_CPack SecName |
| 123 |
; This macro is used to call section's Remove_... macro |
| 124 |
;from the uninstaller. |
| 125 |
;Input: section index constant name specified in Section command. |
| 126 |
|
| 127 |
!insertmacro "Remove_${${SecName}}" |
| 128 |
!macroend |
| 129 |
|
| 130 |
; Determine whether the selection of SecName changed |
| 131 |
!macro MaybeSelectionChanged SecName |
| 132 |
!insertmacro LoadVar ${SecName}_selected |
| 133 |
SectionGetFlags ${${SecName}} $R1 |
| 134 |
IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits |
| 135 |
|
| 136 |
; See if the status has changed: |
| 137 |
IntCmp $R0 $R1 "${SecName}_unchanged" |
| 138 |
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected |
| 139 |
|
| 140 |
IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected" |
| 141 |
!insertmacro "Deselect_required_by_${SecName}" |
| 142 |
goto "${SecName}_unchanged" |
| 143 |
|
| 144 |
"${SecName}_was_selected:" |
| 145 |
!insertmacro "Select_${SecName}_depends" |
| 146 |
|
| 147 |
"${SecName}_unchanged:" |
| 148 |
!macroend |
| 149 |
;--- End of Add/Remove macros --- |
| 150 |
|
| 151 |
;-------------------------------- |
| 152 |
;Interface Settings |
| 153 |
|
| 154 |
!define MUI_HEADERIMAGE |
| 155 |
!define MUI_ABORTWARNING |
| 156 |
|
| 157 |
;-------------------------------- |
| 158 |
; path functions |
| 159 |
|
| 160 |
!verbose 3 |
| 161 |
!include "WinMessages.NSH" |
| 162 |
!verbose 4 |
| 163 |
|
| 164 |
;---------------------------------------- |
| 165 |
; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02" |
| 166 |
;---------------------------------------- |
| 167 |
!verbose 3 |
| 168 |
!include "WinMessages.NSH" |
| 169 |
!verbose 4 |
| 170 |
;==================================================== |
| 171 |
; get_NT_environment |
| 172 |
; Returns: the selected environment |
| 173 |
; Output : head of the stack |
| 174 |
;==================================================== |
| 175 |
!macro select_NT_profile UN |
| 176 |
Function ${UN}select_NT_profile |
| 177 |
StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single |
| 178 |
DetailPrint "Selected environment for all users" |
| 179 |
Push "all" |
| 180 |
Return |
| 181 |
environment_single: |
| 182 |
DetailPrint "Selected environment for current user only." |
| 183 |
Push "current" |
| 184 |
Return |
| 185 |
FunctionEnd |
| 186 |
!macroend |
| 187 |
!insertmacro select_NT_profile "" |
| 188 |
!insertmacro select_NT_profile "un." |
| 189 |
;---------------------------------------------------- |
| 190 |
!define NT_current_env 'HKCU "Environment"' |
| 191 |
!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' |
| 192 |
|
| 193 |
!ifndef WriteEnvStr_RegKey |
| 194 |
!ifdef ALL_USERS |
| 195 |
!define WriteEnvStr_RegKey \ |
| 196 |
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' |
| 197 |
!else |
| 198 |
!define WriteEnvStr_RegKey 'HKCU "Environment"' |
| 199 |
!endif |
| 200 |
!endif |
| 201 |
|
| 202 |
; AddToPath - Adds the given dir to the search path. |
| 203 |
; Input - head of the stack |
| 204 |
; Note - Win9x systems requires reboot |
| 205 |
|
| 206 |
Function AddToPath |
| 207 |
Exch $0 |
| 208 |
Push $1 |
| 209 |
Push $2 |
| 210 |
Push $3 |
| 211 |
|
| 212 |
# don't add if the path doesn't exist |
| 213 |
IfFileExists "$0\*.*" "" AddToPath_done |
| 214 |
|
| 215 |
ReadEnvStr $1 PATH |
| 216 |
; if the path is too long for a NSIS variable NSIS will return a 0 |
| 217 |
; length string. If we find that, then warn and skip any path |
| 218 |
; modification as it will trash the existing path. |
| 219 |
StrLen $2 $1 |
| 220 |
IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done |
| 221 |
CheckPathLength_ShowPathWarning: |
| 222 |
Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!" |
| 223 |
Goto AddToPath_done |
| 224 |
CheckPathLength_Done: |
| 225 |
Push "$1;" |
| 226 |
Push "$0;" |
| 227 |
Call StrStr |
| 228 |
Pop $2 |
| 229 |
StrCmp $2 "" "" AddToPath_done |
| 230 |
Push "$1;" |
| 231 |
Push "$0\;" |
| 232 |
Call StrStr |
| 233 |
Pop $2 |
| 234 |
StrCmp $2 "" "" AddToPath_done |
| 235 |
GetFullPathName /SHORT $3 $0 |
| 236 |
Push "$1;" |
| 237 |
Push "$3;" |
| 238 |
Call StrStr |
| 239 |
Pop $2 |
| 240 |
StrCmp $2 "" "" AddToPath_done |
| 241 |
Push "$1;" |
| 242 |
Push "$3\;" |
| 243 |
Call StrStr |
| 244 |
Pop $2 |
| 245 |
StrCmp $2 "" "" AddToPath_done |
| 246 |
|
| 247 |
Call IsNT |
| 248 |
Pop $1 |
| 249 |
StrCmp $1 1 AddToPath_NT |
| 250 |
; Not on NT |
| 251 |
StrCpy $1 $WINDIR 2 |
| 252 |
FileOpen $1 "$1\autoexec.bat" a |
| 253 |
FileSeek $1 -1 END |
| 254 |
FileReadByte $1 $2 |
| 255 |
IntCmp $2 26 0 +2 +2 # DOS EOF |
| 256 |
FileSeek $1 -1 END # write over EOF |
| 257 |
FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n" |
| 258 |
FileClose $1 |
| 259 |
SetRebootFlag true |
| 260 |
Goto AddToPath_done |
| 261 |
|
| 262 |
AddToPath_NT: |
| 263 |
StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey |
| 264 |
ReadRegStr $1 ${NT_current_env} "PATH" |
| 265 |
Goto DoTrim |
| 266 |
ReadAllKey: |
| 267 |
ReadRegStr $1 ${NT_all_env} "PATH" |
| 268 |
DoTrim: |
| 269 |
StrCmp $1 "" AddToPath_NTdoIt |
| 270 |
Push $1 |
| 271 |
Call Trim |
| 272 |
Pop $1 |
| 273 |
StrCpy $0 "$1;$0" |
| 274 |
AddToPath_NTdoIt: |
| 275 |
StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey |
| 276 |
WriteRegExpandStr ${NT_current_env} "PATH" $0 |
| 277 |
Goto DoSend |
| 278 |
WriteAllKey: |
| 279 |
WriteRegExpandStr ${NT_all_env} "PATH" $0 |
| 280 |
DoSend: |
| 281 |
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 |
| 282 |
|
| 283 |
AddToPath_done: |
| 284 |
Pop $3 |
| 285 |
Pop $2 |
| 286 |
Pop $1 |
| 287 |
Pop $0 |
| 288 |
FunctionEnd |
| 289 |
|
| 290 |
|
| 291 |
; RemoveFromPath - Remove a given dir from the path |
| 292 |
; Input: head of the stack |
| 293 |
|
| 294 |
Function un.RemoveFromPath |
| 295 |
Exch $0 |
| 296 |
Push $1 |
| 297 |
Push $2 |
| 298 |
Push $3 |
| 299 |
Push $4 |
| 300 |
Push $5 |
| 301 |
Push $6 |
| 302 |
|
| 303 |
IntFmt $6 "%c" 26 # DOS EOF |
| 304 |
|
| 305 |
Call un.IsNT |
| 306 |
Pop $1 |
| 307 |
StrCmp $1 1 unRemoveFromPath_NT |
| 308 |
; Not on NT |
| 309 |
StrCpy $1 $WINDIR 2 |
| 310 |
FileOpen $1 "$1\autoexec.bat" r |
| 311 |
GetTempFileName $4 |
| 312 |
FileOpen $2 $4 w |
| 313 |
GetFullPathName /SHORT $0 $0 |
| 314 |
StrCpy $0 "SET PATH=%PATH%;$0" |
| 315 |
Goto unRemoveFromPath_dosLoop |
| 316 |
|
| 317 |
unRemoveFromPath_dosLoop: |
| 318 |
FileRead $1 $3 |
| 319 |
StrCpy $5 $3 1 -1 # read last char |
| 320 |
StrCmp $5 $6 0 +2 # if DOS EOF |
| 321 |
StrCpy $3 $3 -1 # remove DOS EOF so we can compare |
| 322 |
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine |
| 323 |
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine |
| 324 |
StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine |
| 325 |
StrCmp $3 "" unRemoveFromPath_dosLoopEnd |
| 326 |
FileWrite $2 $3 |
| 327 |
Goto unRemoveFromPath_dosLoop |
| 328 |
unRemoveFromPath_dosLoopRemoveLine: |
| 329 |
SetRebootFlag true |
| 330 |
Goto unRemoveFromPath_dosLoop |
| 331 |
|
| 332 |
unRemoveFromPath_dosLoopEnd: |
| 333 |
FileClose $2 |
| 334 |
FileClose $1 |
| 335 |
StrCpy $1 $WINDIR 2 |
| 336 |
Delete "$1\autoexec.bat" |
| 337 |
CopyFiles /SILENT $4 "$1\autoexec.bat" |
| 338 |
Delete $4 |
| 339 |
Goto unRemoveFromPath_done |
| 340 |
|
| 341 |
unRemoveFromPath_NT: |
| 342 |
StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey |
| 343 |
ReadRegStr $1 ${NT_current_env} "PATH" |
| 344 |
Goto unDoTrim |
| 345 |
unReadAllKey: |
| 346 |
ReadRegStr $1 ${NT_all_env} "PATH" |
| 347 |
unDoTrim: |
| 348 |
StrCpy $5 $1 1 -1 # copy last char |
| 349 |
StrCmp $5 ";" +2 # if last char != ; |
| 350 |
StrCpy $1 "$1;" # append ; |
| 351 |
Push $1 |
| 352 |
Push "$0;" |
| 353 |
Call un.StrStr ; Find `$0;` in $1 |
| 354 |
Pop $2 ; pos of our dir |
| 355 |
StrCmp $2 "" unRemoveFromPath_done |
| 356 |
; else, it is in path |
| 357 |
# $0 - path to add |
| 358 |
# $1 - path var |
| 359 |
StrLen $3 "$0;" |
| 360 |
StrLen $4 $2 |
| 361 |
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove |
| 362 |
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove |
| 363 |
StrCpy $3 $5$6 |
| 364 |
|
| 365 |
StrCpy $5 $3 1 -1 # copy last char |
| 366 |
StrCmp $5 ";" 0 +2 # if last char == ; |
| 367 |
StrCpy $3 $3 -1 # remove last char |
| 368 |
|
| 369 |
StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey |
| 370 |
WriteRegExpandStr ${NT_current_env} "PATH" $3 |
| 371 |
Goto unDoSend |
| 372 |
unWriteAllKey: |
| 373 |
WriteRegExpandStr ${NT_all_env} "PATH" $3 |
| 374 |
unDoSend: |
| 375 |
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 |
| 376 |
|
| 377 |
unRemoveFromPath_done: |
| 378 |
Pop $6 |
| 379 |
Pop $5 |
| 380 |
Pop $4 |
| 381 |
Pop $3 |
| 382 |
Pop $2 |
| 383 |
Pop $1 |
| 384 |
Pop $0 |
| 385 |
FunctionEnd |
| 386 |
|
| 387 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 388 |
; Uninstall sutff |
| 389 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 390 |
|
| 391 |
########################################### |
| 392 |
# Utility Functions # |
| 393 |
########################################### |
| 394 |
|
| 395 |
;==================================================== |
| 396 |
; IsNT - Returns 1 if the current system is NT, 0 |
| 397 |
; otherwise. |
| 398 |
; Output: head of the stack |
| 399 |
;==================================================== |
| 400 |
; IsNT |
| 401 |
; no input |
| 402 |
; output, top of the stack = 1 if NT or 0 if not |
| 403 |
; |
| 404 |
; Usage: |
| 405 |
; Call IsNT |
| 406 |
; Pop $R0 |
| 407 |
; ($R0 at this point is 1 or 0) |
| 408 |
|
| 409 |
!macro IsNT un |
| 410 |
Function ${un}IsNT |
| 411 |
Push $0 |
| 412 |
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion |
| 413 |
StrCmp $0 "" 0 IsNT_yes |
| 414 |
; we are not NT. |
| 415 |
Pop $0 |
| 416 |
Push 0 |
| 417 |
Return |
| 418 |
|
| 419 |
IsNT_yes: |
| 420 |
; NT!!! |
| 421 |
Pop $0 |
| 422 |
Push 1 |
| 423 |
FunctionEnd |
| 424 |
!macroend |
| 425 |
!insertmacro IsNT "" |
| 426 |
!insertmacro IsNT "un." |
| 427 |
|
| 428 |
; StrStr |
| 429 |
; input, top of stack = string to search for |
| 430 |
; top of stack-1 = string to search in |
| 431 |
; output, top of stack (replaces with the portion of the string remaining) |
| 432 |
; modifies no other variables. |
| 433 |
; |
| 434 |
; Usage: |
| 435 |
; Push "this is a long ass string" |
| 436 |
; Push "ass" |
| 437 |
; Call StrStr |
| 438 |
; Pop $R0 |
| 439 |
; ($R0 at this point is "ass string") |
| 440 |
|
| 441 |
!macro StrStr un |
| 442 |
Function ${un}StrStr |
| 443 |
Exch $R1 ; st=haystack,old$R1, $R1=needle |
| 444 |
Exch ; st=old$R1,haystack |
| 445 |
Exch $R2 ; st=old$R1,old$R2, $R2=haystack |
| 446 |
Push $R3 |
| 447 |
Push $R4 |
| 448 |
Push $R5 |
| 449 |
StrLen $R3 $R1 |
| 450 |
StrCpy $R4 0 |
| 451 |
; $R1=needle |
| 452 |
; $R2=haystack |
| 453 |
; $R3=len(needle) |
| 454 |
; $R4=cnt |
| 455 |
; $R5=tmp |
| 456 |
loop: |
| 457 |
StrCpy $R5 $R2 $R3 $R4 |
| 458 |
StrCmp $R5 $R1 done |
| 459 |
StrCmp $R5 "" done |
| 460 |
IntOp $R4 $R4 + 1 |
| 461 |
Goto loop |
| 462 |
done: |
| 463 |
StrCpy $R1 $R2 "" $R4 |
| 464 |
Pop $R5 |
| 465 |
Pop $R4 |
| 466 |
Pop $R3 |
| 467 |
Pop $R2 |
| 468 |
Exch $R1 |
| 469 |
FunctionEnd |
| 470 |
!macroend |
| 471 |
!insertmacro StrStr "" |
| 472 |
!insertmacro StrStr "un." |
| 473 |
|
| 474 |
Function Trim ; Added by Pelaca |
| 475 |
Exch $R1 |
| 476 |
Push $R2 |
| 477 |
Loop: |
| 478 |
StrCpy $R2 "$R1" 1 -1 |
| 479 |
StrCmp "$R2" " " RTrim |
| 480 |
StrCmp "$R2" "$\n" RTrim |
| 481 |
StrCmp "$R2" "$\r" RTrim |
| 482 |
StrCmp "$R2" ";" RTrim |
| 483 |
GoTo Done |
| 484 |
RTrim: |
| 485 |
StrCpy $R1 "$R1" -1 |
| 486 |
Goto Loop |
| 487 |
Done: |
| 488 |
Pop $R2 |
| 489 |
Exch $R1 |
| 490 |
FunctionEnd |
| 491 |
|
| 492 |
Function ConditionalAddToRegisty |
| 493 |
Pop $0 |
| 494 |
Pop $1 |
| 495 |
StrCmp "$0" "" ConditionalAddToRegisty_EmptyString |
| 496 |
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \ |
| 497 |
"$1" "$0" |
| 498 |
;MessageBox MB_OK "Set Registry: '$1' to '$0'" |
| 499 |
DetailPrint "Set install registry entry: '$1' to '$0'" |
| 500 |
ConditionalAddToRegisty_EmptyString: |
| 501 |
FunctionEnd |
| 502 |
|
| 503 |
;-------------------------------- |
| 504 |
|
| 505 |
!ifdef CPACK_USES_DOWNLOAD |
| 506 |
Function DownloadFile |
| 507 |
IfFileExists $INSTDIR\* +2 |
| 508 |
CreateDirectory $INSTDIR |
| 509 |
Pop $0 |
| 510 |
|
| 511 |
; Skip if already downloaded |
| 512 |
IfFileExists $INSTDIR\$0 0 +2 |
| 513 |
Return |
| 514 |
|
| 515 |
StrCpy $1 "@CPACK_DOWNLOAD_SITE@" |
| 516 |
|
| 517 |
try_again: |
| 518 |
NSISdl::download "$1/$0" "$INSTDIR\$0" |
| 519 |
|
| 520 |
Pop $1 |
| 521 |
StrCmp $1 "success" success |
| 522 |
StrCmp $1 "Cancelled" cancel |
| 523 |
MessageBox MB_OK "Download failed: $1" |
| 524 |
cancel: |
| 525 |
Return |
| 526 |
success: |
| 527 |
FunctionEnd |
| 528 |
!endif |
| 529 |
|
| 530 |
;-------------------------------- |
| 531 |
; Installation types |
| 532 |
@CPACK_NSIS_INSTALLATION_TYPES@ |
| 533 |
|
| 534 |
;-------------------------------- |
| 535 |
; Component sections |
| 536 |
@CPACK_NSIS_COMPONENT_SECTIONS@ |
| 537 |
|
| 538 |
;-------------------------------- |
| 539 |
; Define some macro setting for the gui |
| 540 |
@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ |
| 541 |
@CPACK_NSIS_INSTALLER_ICON_CODE@ |
| 542 |
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ |
| 543 |
@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@ |
| 544 |
|
| 545 |
;-------------------------------- |
| 546 |
;Pages |
| 547 |
!insertmacro MUI_PAGE_WELCOME |
| 548 |
|
| 549 |
!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" |
| 550 |
Page custom InstallOptionsPage |
| 551 |
!insertmacro MUI_PAGE_DIRECTORY |
| 552 |
|
| 553 |
;Start Menu Folder Page Configuration |
| 554 |
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" |
| 555 |
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" |
| 556 |
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" |
| 557 |
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER |
| 558 |
|
| 559 |
@CPACK_NSIS_PAGE_COMPONENTS@ |
| 560 |
|
| 561 |
!insertmacro MUI_PAGE_INSTFILES |
| 562 |
!insertmacro MUI_PAGE_FINISH |
| 563 |
|
| 564 |
!insertmacro MUI_UNPAGE_CONFIRM |
| 565 |
!insertmacro MUI_UNPAGE_INSTFILES |
| 566 |
|
| 567 |
;-------------------------------- |
| 568 |
;Languages |
| 569 |
|
| 570 |
!insertmacro MUI_LANGUAGE "English" ;first language is the default language |
| 571 |
!insertmacro MUI_LANGUAGE "Albanian" |
| 572 |
!insertmacro MUI_LANGUAGE "Arabic" |
| 573 |
!insertmacro MUI_LANGUAGE "Basque" |
| 574 |
!insertmacro MUI_LANGUAGE "Belarusian" |
| 575 |
!insertmacro MUI_LANGUAGE "Bosnian" |
| 576 |
!insertmacro MUI_LANGUAGE "Breton" |
| 577 |
!insertmacro MUI_LANGUAGE "Bulgarian" |
| 578 |
!insertmacro MUI_LANGUAGE "Croatian" |
| 579 |
!insertmacro MUI_LANGUAGE "Czech" |
| 580 |
!insertmacro MUI_LANGUAGE "Danish" |
| 581 |
!insertmacro MUI_LANGUAGE "Dutch" |
| 582 |
!insertmacro MUI_LANGUAGE "Estonian" |
| 583 |
!insertmacro MUI_LANGUAGE "Farsi" |
| 584 |
!insertmacro MUI_LANGUAGE "Finnish" |
| 585 |
!insertmacro MUI_LANGUAGE "French" |
| 586 |
!insertmacro MUI_LANGUAGE "German" |
| 587 |
!insertmacro MUI_LANGUAGE "Greek" |
| 588 |
!insertmacro MUI_LANGUAGE "Hebrew" |
| 589 |
!insertmacro MUI_LANGUAGE "Hungarian" |
| 590 |
!insertmacro MUI_LANGUAGE "Icelandic" |
| 591 |
!insertmacro MUI_LANGUAGE "Indonesian" |
| 592 |
!insertmacro MUI_LANGUAGE "Irish" |
| 593 |
!insertmacro MUI_LANGUAGE "Italian" |
| 594 |
!insertmacro MUI_LANGUAGE "Japanese" |
| 595 |
!insertmacro MUI_LANGUAGE "Korean" |
| 596 |
!insertmacro MUI_LANGUAGE "Kurdish" |
| 597 |
!insertmacro MUI_LANGUAGE "Latvian" |
| 598 |
!insertmacro MUI_LANGUAGE "Lithuanian" |
| 599 |
!insertmacro MUI_LANGUAGE "Luxembourgish" |
| 600 |
!insertmacro MUI_LANGUAGE "Macedonian" |
| 601 |
!insertmacro MUI_LANGUAGE "Malay" |
| 602 |
!insertmacro MUI_LANGUAGE "Mongolian" |
| 603 |
!insertmacro MUI_LANGUAGE "Norwegian" |
| 604 |
!insertmacro MUI_LANGUAGE "Polish" |
| 605 |
!insertmacro MUI_LANGUAGE "Portuguese" |
| 606 |
!insertmacro MUI_LANGUAGE "PortugueseBR" |
| 607 |
!insertmacro MUI_LANGUAGE "Romanian" |
| 608 |
!insertmacro MUI_LANGUAGE "Russian" |
| 609 |
!insertmacro MUI_LANGUAGE "Serbian" |
| 610 |
!insertmacro MUI_LANGUAGE "SerbianLatin" |
| 611 |
!insertmacro MUI_LANGUAGE "SimpChinese" |
| 612 |
!insertmacro MUI_LANGUAGE "Slovak" |
| 613 |
!insertmacro MUI_LANGUAGE "Slovenian" |
| 614 |
!insertmacro MUI_LANGUAGE "Spanish" |
| 615 |
!insertmacro MUI_LANGUAGE "Swedish" |
| 616 |
!insertmacro MUI_LANGUAGE "Thai" |
| 617 |
!insertmacro MUI_LANGUAGE "TradChinese" |
| 618 |
!insertmacro MUI_LANGUAGE "Turkish" |
| 619 |
!insertmacro MUI_LANGUAGE "Ukrainian" |
| 620 |
!insertmacro MUI_LANGUAGE "Welsh" |
| 621 |
|
| 622 |
|
| 623 |
;-------------------------------- |
| 624 |
;Reserve Files |
| 625 |
|
| 626 |
;These files should be inserted before other files in the data block |
| 627 |
;Keep these lines before any File command |
| 628 |
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA) |
| 629 |
|
| 630 |
ReserveFile "NSIS.InstallOptions.ini" |
| 631 |
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS |
| 632 |
|
| 633 |
;-------------------------------- |
| 634 |
;Installer Sections |
| 635 |
|
| 636 |
Section "-Core installation" |
| 637 |
;Use the entire tree produced by the INSTALL target. Keep the |
| 638 |
;list of directories here in sync with the RMDir commands below. |
| 639 |
SetOutPath "$INSTDIR" |
| 640 |
@CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@ |
| 641 |
@CPACK_NSIS_FULL_INSTALL@ |
| 642 |
|
| 643 |
;Store installation folder |
| 644 |
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR |
| 645 |
|
| 646 |
;Create uninstaller |
| 647 |
WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 648 |
Push "DisplayName" |
| 649 |
Push "@CPACK_NSIS_DISPLAY_NAME@" |
| 650 |
Call ConditionalAddToRegisty |
| 651 |
Push "DisplayVersion" |
| 652 |
Push "@CPACK_PACKAGE_VERSION@" |
| 653 |
Call ConditionalAddToRegisty |
| 654 |
Push "Publisher" |
| 655 |
Push "@CPACK_PACKAGE_VENDOR@" |
| 656 |
Call ConditionalAddToRegisty |
| 657 |
Push "UninstallString" |
| 658 |
Push "$INSTDIR\Uninstall.exe" |
| 659 |
Call ConditionalAddToRegisty |
| 660 |
Push "NoRepair" |
| 661 |
Push "1" |
| 662 |
Call ConditionalAddToRegisty |
| 663 |
|
| 664 |
!ifdef CPACK_NSIS_ADD_REMOVE |
| 665 |
;Create add/remove functionality |
| 666 |
Push "ModifyPath" |
| 667 |
Push "$INSTDIR\AddRemove.exe" |
| 668 |
Call ConditionalAddToRegisty |
| 669 |
!else |
| 670 |
Push "NoModify" |
| 671 |
Push "1" |
| 672 |
Call ConditionalAddToRegisty |
| 673 |
!endif |
| 674 |
|
| 675 |
; Optional registration |
| 676 |
Push "DisplayIcon" |
| 677 |
Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" |
| 678 |
Call ConditionalAddToRegisty |
| 679 |
Push "HelpLink" |
| 680 |
Push "@CPACK_NSIS_HELP_LINK@" |
| 681 |
Call ConditionalAddToRegisty |
| 682 |
Push "URLInfoAbout" |
| 683 |
Push "@CPACK_NSIS_URL_INFO_ABOUT@" |
| 684 |
Call ConditionalAddToRegisty |
| 685 |
Push "Contact" |
| 686 |
Push "@CPACK_NSIS_CONTACT@" |
| 687 |
Call ConditionalAddToRegisty |
| 688 |
!insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State" |
| 689 |
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
| 690 |
|
| 691 |
;Create shortcuts |
| 692 |
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" |
| 693 |
@CPACK_NSIS_CREATE_ICONS@ |
| 694 |
@CPACK_NSIS_CREATE_ICONS_EXTRA@ |
| 695 |
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" |
| 696 |
|
| 697 |
;Read a value from an InstallOptions INI file |
| 698 |
!insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" |
| 699 |
!insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State" |
| 700 |
!insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State" |
| 701 |
|
| 702 |
; Write special uninstall registry entries |
| 703 |
Push "StartMenu" |
| 704 |
Push "$STARTMENU_FOLDER" |
| 705 |
Call ConditionalAddToRegisty |
| 706 |
Push "DoNotAddToPath" |
| 707 |
Push "$DO_NOT_ADD_TO_PATH" |
| 708 |
Call ConditionalAddToRegisty |
| 709 |
Push "AddToPathAllUsers" |
| 710 |
Push "$ADD_TO_PATH_ALL_USERS" |
| 711 |
Call ConditionalAddToRegisty |
| 712 |
Push "AddToPathCurrentUser" |
| 713 |
Push "$ADD_TO_PATH_CURRENT_USER" |
| 714 |
Call ConditionalAddToRegisty |
| 715 |
Push "InstallToDesktop" |
| 716 |
Push "$INSTALL_DESKTOP" |
| 717 |
Call ConditionalAddToRegisty |
| 718 |
|
| 719 |
!insertmacro MUI_STARTMENU_WRITE_END |
| 720 |
|
| 721 |
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@ |
| 722 |
|
| 723 |
SectionEnd |
| 724 |
|
| 725 |
Section "-Add to path" |
| 726 |
Push $INSTDIR\bin |
| 727 |
StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath |
| 728 |
StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 |
| 729 |
Call AddToPath |
| 730 |
doNotAddToPath: |
| 731 |
SectionEnd |
| 732 |
|
| 733 |
;-------------------------------- |
| 734 |
; Create custom pages |
| 735 |
Function InstallOptionsPage |
| 736 |
!insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@" |
| 737 |
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini" |
| 738 |
|
| 739 |
FunctionEnd |
| 740 |
|
| 741 |
;-------------------------------- |
| 742 |
; determine admin versus local install |
| 743 |
Function un.onInit |
| 744 |
|
| 745 |
ClearErrors |
| 746 |
UserInfo::GetName |
| 747 |
IfErrors noLM |
| 748 |
Pop $0 |
| 749 |
UserInfo::GetAccountType |
| 750 |
Pop $1 |
| 751 |
StrCmp $1 "Admin" 0 +3 |
| 752 |
SetShellVarContext all |
| 753 |
;MessageBox MB_OK 'User "$0" is in the Admin group' |
| 754 |
Goto done |
| 755 |
StrCmp $1 "Power" 0 +3 |
| 756 |
SetShellVarContext all |
| 757 |
;MessageBox MB_OK 'User "$0" is in the Power Users group' |
| 758 |
Goto done |
| 759 |
|
| 760 |
noLM: |
| 761 |
;Get installation folder from registry if available |
| 762 |
|
| 763 |
done: |
| 764 |
|
| 765 |
FunctionEnd |
| 766 |
|
| 767 |
;--- Add/Remove callback functions: --- |
| 768 |
!macro SectionList MacroName |
| 769 |
;This macro used to perform operation on multiple sections. |
| 770 |
;List all of your components in following manner here. |
| 771 |
@CPACK_NSIS_COMPONENT_SECTION_LIST@ |
| 772 |
!macroend |
| 773 |
|
| 774 |
Section -FinishComponents |
| 775 |
;Removes unselected components and writes component status to registry |
| 776 |
!insertmacro SectionList "FinishSection" |
| 777 |
|
| 778 |
!ifdef CPACK_NSIS_ADD_REMOVE |
| 779 |
; Get the name of the installer executable |
| 780 |
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' |
| 781 |
StrCpy $R3 $R0 |
| 782 |
|
| 783 |
; Strip off the last 13 characters, to see if we have AddRemove.exe |
| 784 |
StrLen $R1 $R0 |
| 785 |
IntOp $R1 $R0 - 13 |
| 786 |
StrCpy $R2 $R0 13 $R1 |
| 787 |
StrCmp $R2 "AddRemove.exe" addremove_installed |
| 788 |
|
| 789 |
; We're not running AddRemove.exe, so install it |
| 790 |
CopyFiles $R3 $INSTDIR\AddRemove.exe |
| 791 |
|
| 792 |
addremove_installed: |
| 793 |
!endif |
| 794 |
SectionEnd |
| 795 |
;--- End of Add/Remove callback functions --- |
| 796 |
|
| 797 |
;-------------------------------- |
| 798 |
; Component dependencies |
| 799 |
Function .onSelChange |
| 800 |
!insertmacro SectionList MaybeSelectionChanged |
| 801 |
FunctionEnd |
| 802 |
|
| 803 |
;-------------------------------- |
| 804 |
;Uninstaller Section |
| 805 |
|
| 806 |
Section "Uninstall" |
| 807 |
ReadRegStr $START_MENU SHCTX \ |
| 808 |
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu" |
| 809 |
;MessageBox MB_OK "Start menu is in: $START_MENU" |
| 810 |
ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \ |
| 811 |
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath" |
| 812 |
ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \ |
| 813 |
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers" |
| 814 |
ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \ |
| 815 |
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser" |
| 816 |
;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS" |
| 817 |
ReadRegStr $INSTALL_DESKTOP SHCTX \ |
| 818 |
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop" |
| 819 |
;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP " |
| 820 |
|
| 821 |
@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@ |
| 822 |
|
| 823 |
;Remove files we installed. |
| 824 |
;Keep the list of directories here in sync with the File commands above. |
| 825 |
@CPACK_NSIS_DELETE_FILES@ |
| 826 |
@CPACK_NSIS_DELETE_DIRECTORIES@ |
| 827 |
|
| 828 |
!ifdef CPACK_NSIS_ADD_REMOVE |
| 829 |
;Remove the add/remove program |
| 830 |
Delete "$INSTDIR\AddRemove.exe" |
| 831 |
!endif |
| 832 |
|
| 833 |
;Remove the uninstaller itself. |
| 834 |
Delete "$INSTDIR\Uninstall.exe" |
| 835 |
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" |
| 836 |
|
| 837 |
;Remove the installation directory if it is empty. |
| 838 |
RMDir "$INSTDIR" |
| 839 |
|
| 840 |
; Remove the registry entries. |
| 841 |
DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" |
| 842 |
|
| 843 |
; Removes all optional components |
| 844 |
!insertmacro SectionList "RemoveSection_CPack" |
| 845 |
|
| 846 |
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
| 847 |
|
| 848 |
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" |
| 849 |
@CPACK_NSIS_DELETE_ICONS@ |
| 850 |
@CPACK_NSIS_DELETE_ICONS_EXTRA@ |
| 851 |
|
| 852 |
;Delete empty start menu parent diretories |
| 853 |
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" |
| 854 |
|
| 855 |
startMenuDeleteLoop: |
| 856 |
ClearErrors |
| 857 |
RMDir $MUI_TEMP |
| 858 |
GetFullPathName $MUI_TEMP "$MUI_TEMP\.." |
| 859 |
|
| 860 |
IfErrors startMenuDeleteLoopDone |
| 861 |
|
| 862 |
StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop |
| 863 |
startMenuDeleteLoopDone: |
| 864 |
|
| 865 |
; If the user changed the shortcut, then untinstall may not work. This should |
| 866 |
; try to fix it. |
| 867 |
StrCpy $MUI_TEMP "$START_MENU" |
| 868 |
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" |
| 869 |
@CPACK_NSIS_DELETE_ICONS_EXTRA@ |
| 870 |
|
| 871 |
;Delete empty start menu parent diretories |
| 872 |
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" |
| 873 |
|
| 874 |
secondStartMenuDeleteLoop: |
| 875 |
ClearErrors |
| 876 |
RMDir $MUI_TEMP |
| 877 |
GetFullPathName $MUI_TEMP "$MUI_TEMP\.." |
| 878 |
|
| 879 |
IfErrors secondStartMenuDeleteLoopDone |
| 880 |
|
| 881 |
StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop |
| 882 |
secondStartMenuDeleteLoopDone: |
| 883 |
|
| 884 |
DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" |
| 885 |
|
| 886 |
Push $INSTDIR\bin |
| 887 |
StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0 |
| 888 |
Call un.RemoveFromPath |
| 889 |
doNotRemoveFromPath: |
| 890 |
SectionEnd |
| 891 |
|
| 892 |
;-------------------------------- |
| 893 |
; determine admin versus local install |
| 894 |
; Is install for "AllUsers" or "JustMe"? |
| 895 |
; Default to "JustMe" - set to "AllUsers" if admin or on Win9x |
| 896 |
; This function is used for the very first "custom page" of the installer. |
| 897 |
; This custom page does not show up visibly, but it executes prior to the |
| 898 |
; first visible page and sets up $INSTDIR properly... |
| 899 |
; Choose different default installation folder based on SV_ALLUSERS... |
| 900 |
; "Program Files" for AllUsers, "My Documents" for JustMe... |
| 901 |
|
| 902 |
Function .onInit |
| 903 |
StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst |
| 904 |
|
| 905 |
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString" |
| 906 |
StrCmp $0 "" inst |
| 907 |
|
| 908 |
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \ |
| 909 |
"@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \ |
| 910 |
IDYES uninst IDNO inst |
| 911 |
Abort |
| 912 |
|
| 913 |
;Run the uninstaller |
| 914 |
uninst: |
| 915 |
ClearErrors |
| 916 |
StrLen $2 "\Uninstall.exe" |
| 917 |
StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path |
| 918 |
ExecWait '$0 _?=$3' ;Do not copy the uninstaller to a temp file |
| 919 |
|
| 920 |
IfErrors uninst_failed inst |
| 921 |
uninst_failed: |
| 922 |
MessageBox MB_OK|MB_ICONSTOP "Uninstall failed." |
| 923 |
Abort |
| 924 |
|
| 925 |
|
| 926 |
inst: |
| 927 |
; Reads components status for registry |
| 928 |
!insertmacro SectionList "InitSection" |
| 929 |
|
| 930 |
; check to see if /D has been used to change |
| 931 |
; the install directory by comparing it to the |
| 932 |
; install directory that is expected to be the |
| 933 |
; default |
| 934 |
StrCpy $IS_DEFAULT_INSTALLDIR 0 |
| 935 |
StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2 |
| 936 |
StrCpy $IS_DEFAULT_INSTALLDIR 1 |
| 937 |
|
| 938 |
StrCpy $SV_ALLUSERS "JustMe" |
| 939 |
; if default install dir then change the default |
| 940 |
; if it is installed for JustMe |
| 941 |
StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 |
| 942 |
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" |
| 943 |
|
| 944 |
ClearErrors |
| 945 |
UserInfo::GetName |
| 946 |
IfErrors noLM |
| 947 |
Pop $0 |
| 948 |
UserInfo::GetAccountType |
| 949 |
Pop $1 |
| 950 |
StrCmp $1 "Admin" 0 +4 |
| 951 |
SetShellVarContext all |
| 952 |
;MessageBox MB_OK 'User "$0" is in the Admin group' |
| 953 |
StrCpy $SV_ALLUSERS "AllUsers" |
| 954 |
Goto done |
| 955 |
StrCmp $1 "Power" 0 +4 |
| 956 |
SetShellVarContext all |
| 957 |
;MessageBox MB_OK 'User "$0" is in the Power Users group' |
| 958 |
StrCpy $SV_ALLUSERS "AllUsers" |
| 959 |
Goto done |
| 960 |
|
| 961 |
noLM: |
| 962 |
StrCpy $SV_ALLUSERS "AllUsers" |
| 963 |
;Get installation folder from registry if available |
| 964 |
|
| 965 |
done: |
| 966 |
StrCmp $SV_ALLUSERS "AllUsers" 0 +3 |
| 967 |
StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 |
| 968 |
StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" |
| 969 |
|
| 970 |
StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage |
| 971 |
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" |
| 972 |
|
| 973 |
noOptionsPage: |
| 974 |
FunctionEnd |