1 ; CPack install script designed for a nmake build
3 ;--------------------------------
4 ; You must define these values
6 !define VERSION "@CPACK_PACKAGE_VERSION@"
7 !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
8 !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
10 ;--------------------------------
17 Var DO_NOT_ADD_TO_PATH
18 Var ADD_TO_PATH_ALL_USERS
19 Var ADD_TO_PATH_CURRENT_USER
22 ;--------------------------------
27 ;Default installation folder
28 InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
30 ;--------------------------------
34 Name "@CPACK_PACKAGE_INSTALL_DIRECTORY@"
35 OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
38 SetCompressor @CPACK_NSIS_COMPRESSOR@
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.
51 @CPACK_NSIS_SECTION_SELECTED_VARS@
53 ; Loads the "selected" flag for the section named SecName into the
55 !macro LoadSectionSelectedIntoVar SecName VarName
56 SectionGetFlags ${${SecName}} $${VarName}
57 IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
60 ; Loads the value of a variable... can we get around this?
61 !macro LoadVar VarName
62 IntOp $R0 0 + $${VarName}
65 ; Sets the value of a variable
66 !macro StoreVar VarName IntValue
67 IntOp $${VarName} 0 + ${IntValue}
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.
76 ;Reading component status from registry
77 ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\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
86 ; Note whether this component was installed before
87 !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
88 IntOp $R0 $AR_RegFlags & $AR_RegFlags
90 ;Writing modified flags
91 SectionSetFlags ${${SecName}} $AR_SecFlags
94 !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
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.
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_DIRECTORY@\Components\${SecName}" \
112 Goto "exit_${SecName}"
115 ;Section is selected:
116 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" \
122 !macro RemoveSection 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.
127 !insertmacro "Remove_${${SecName}}"
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
136 ; See if the status has changed:
137 IntCmp $R0 $R1 "${SecName}_unchanged"
138 !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
140 IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
141 !insertmacro "Deselect_required_by_${SecName}"
142 goto "${SecName}_unchanged"
144 "${SecName}_was_selected:"
145 !insertmacro "Select_${SecName}_depends"
147 "${SecName}_unchanged:"
149 ;--- End of Add/Remove macros ---
151 ;--------------------------------
154 !define MUI_HEADERIMAGE
155 !define MUI_ABORTWARNING
157 ;--------------------------------
161 !include "WinMessages.NSH"
164 ;----------------------------------------
165 ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
166 ;----------------------------------------
168 !include "WinMessages.NSH"
170 ;====================================================
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"
182 DetailPrint "Selected environment for current user only."
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"'
193 !ifndef WriteEnvStr_RegKey
195 !define WriteEnvStr_RegKey \
196 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
198 !define WriteEnvStr_RegKey 'HKCU "Environment"'
202 ; AddToPath - Adds the given dir to the search path.
203 ; Input - head of the stack
204 ; Note - Win9x systems requires reboot
212 # don't add if the path doesn't exist
213 IfFileExists "$0\*.*" "" AddToPath_done
220 StrCmp $2 "" "" AddToPath_done
225 StrCmp $2 "" "" AddToPath_done
226 GetFullPathName /SHORT $3 $0
231 StrCmp $2 "" "" AddToPath_done
236 StrCmp $2 "" "" AddToPath_done
240 StrCmp $1 1 AddToPath_NT
243 FileOpen $1 "$1\autoexec.bat" a
246 IntCmp $2 26 0 +2 +2 # DOS EOF
247 FileSeek $1 -1 END # write over EOF
248 FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
254 ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
255 StrCmp $1 "" AddToPath_NTdoIt
261 WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0
262 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
272 ; RemoveFromPath - Remove a given dir from the path
273 ; Input: head of the stack
275 Function un.RemoveFromPath
284 IntFmt $6 "%c" 26 # DOS EOF
288 StrCmp $1 1 unRemoveFromPath_NT
291 FileOpen $1 "$1\autoexec.bat" r
294 GetFullPathName /SHORT $0 $0
295 StrCpy $0 "SET PATH=%PATH%;$0"
296 Goto unRemoveFromPath_dosLoop
298 unRemoveFromPath_dosLoop:
300 StrCpy $5 $3 1 -1 # read last char
301 StrCmp $5 $6 0 +2 # if DOS EOF
302 StrCpy $3 $3 -1 # remove DOS EOF so we can compare
303 StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
304 StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
305 StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
306 StrCmp $3 "" unRemoveFromPath_dosLoopEnd
308 Goto unRemoveFromPath_dosLoop
309 unRemoveFromPath_dosLoopRemoveLine:
311 Goto unRemoveFromPath_dosLoop
313 unRemoveFromPath_dosLoopEnd:
317 Delete "$1\autoexec.bat"
318 CopyFiles /SILENT $4 "$1\autoexec.bat"
320 Goto unRemoveFromPath_done
323 ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
324 StrCpy $5 $1 1 -1 # copy last char
325 StrCmp $5 ";" +2 # if last char != ;
326 StrCpy $1 "$1;" # append ;
329 Call un.StrStr ; Find `$0;` in $1
330 Pop $2 ; pos of our dir
331 StrCmp $2 "" unRemoveFromPath_done
332 ; else, it is in path
337 StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
338 StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
341 StrCpy $5 $3 1 -1 # copy last char
342 StrCmp $5 ";" 0 +2 # if last char == ;
343 StrCpy $3 $3 -1 # remove last char
345 WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3
346 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
348 unRemoveFromPath_done:
358 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362 ###########################################
363 # Utility Functions #
364 ###########################################
366 ;====================================================
367 ; IsNT - Returns 1 if the current system is NT, 0
369 ; Output: head of the stack
370 ;====================================================
373 ; output, top of the stack = 1 if NT or 0 if not
378 ; ($R0 at this point is 1 or 0)
383 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
384 StrCmp $0 "" 0 IsNT_yes
397 !insertmacro IsNT "un."
400 ; input, top of stack = string to search for
401 ; top of stack-1 = string to search in
402 ; output, top of stack (replaces with the portion of the string remaining)
403 ; modifies no other variables.
406 ; Push "this is a long ass string"
410 ; ($R0 at this point is "ass string")
414 Exch $R1 ; st=haystack,old$R1, $R1=needle
415 Exch ; st=old$R1,haystack
416 Exch $R2 ; st=old$R1,old$R2, $R2=haystack
428 StrCpy $R5 $R2 $R3 $R4
434 StrCpy $R1 $R2 "" $R4
442 !insertmacro StrStr ""
443 !insertmacro StrStr "un."
445 Function Trim ; Added by Pelaca
449 StrCpy $R2 "$R1" 1 -1
450 StrCmp "$R2" " " RTrim
451 StrCmp "$R2" "$\n" RTrim
452 StrCmp "$R2" "$\r" RTrim
453 StrCmp "$R2" ";" RTrim
463 Function ConditionalAddToRegisty
466 StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
467 WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" \
469 ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
470 DetailPrint "Set install registry entry: '$1' to '$0'"
471 ConditionalAddToRegisty_EmptyString:
474 ;--------------------------------
476 !ifdef CPACK_USES_DOWNLOAD
477 Function DownloadFile
478 IfFileExists $INSTDIR\* +2
479 CreateDirectory $INSTDIR
482 ; Skip if already downloaded
483 IfFileExists $INSTDIR\$0 0 +2
486 StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
489 NSISdl::download "$1/$0" "$INSTDIR\$0"
492 StrCmp $1 "success" success
493 StrCmp $1 "Cancelled" cancel
494 MessageBox MB_OK "Download failed: $1"
501 ;--------------------------------
503 @CPACK_NSIS_INSTALLATION_TYPES@
505 ;--------------------------------
507 @CPACK_NSIS_COMPONENT_SECTIONS@
509 ;--------------------------------
510 ; Define some macro setting for the gui
511 @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
512 @CPACK_NSIS_INSTALLER_ICON_CODE@
513 @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
515 ;--------------------------------
517 !insertmacro MUI_PAGE_WELCOME
519 !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
520 Page custom InstallOptionsPage
521 !insertmacro MUI_PAGE_DIRECTORY
523 ;Start Menu Folder Page Configuration
524 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
525 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
526 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
527 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
529 @CPACK_NSIS_PAGE_COMPONENTS@
531 !insertmacro MUI_PAGE_INSTFILES
532 !insertmacro MUI_PAGE_FINISH
534 !insertmacro MUI_UNPAGE_CONFIRM
535 !insertmacro MUI_UNPAGE_INSTFILES
537 ;--------------------------------
540 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
541 !insertmacro MUI_LANGUAGE "Albanian"
542 !insertmacro MUI_LANGUAGE "Arabic"
543 !insertmacro MUI_LANGUAGE "Basque"
544 !insertmacro MUI_LANGUAGE "Belarusian"
545 !insertmacro MUI_LANGUAGE "Bosnian"
546 !insertmacro MUI_LANGUAGE "Breton"
547 !insertmacro MUI_LANGUAGE "Bulgarian"
548 !insertmacro MUI_LANGUAGE "Croatian"
549 !insertmacro MUI_LANGUAGE "Czech"
550 !insertmacro MUI_LANGUAGE "Danish"
551 !insertmacro MUI_LANGUAGE "Dutch"
552 !insertmacro MUI_LANGUAGE "Estonian"
553 !insertmacro MUI_LANGUAGE "Farsi"
554 !insertmacro MUI_LANGUAGE "Finnish"
555 !insertmacro MUI_LANGUAGE "French"
556 !insertmacro MUI_LANGUAGE "German"
557 !insertmacro MUI_LANGUAGE "Greek"
558 !insertmacro MUI_LANGUAGE "Hebrew"
559 !insertmacro MUI_LANGUAGE "Hungarian"
560 !insertmacro MUI_LANGUAGE "Icelandic"
561 !insertmacro MUI_LANGUAGE "Indonesian"
562 !insertmacro MUI_LANGUAGE "Irish"
563 !insertmacro MUI_LANGUAGE "Italian"
564 !insertmacro MUI_LANGUAGE "Japanese"
565 !insertmacro MUI_LANGUAGE "Korean"
566 !insertmacro MUI_LANGUAGE "Kurdish"
567 !insertmacro MUI_LANGUAGE "Latvian"
568 !insertmacro MUI_LANGUAGE "Lithuanian"
569 !insertmacro MUI_LANGUAGE "Luxembourgish"
570 !insertmacro MUI_LANGUAGE "Macedonian"
571 !insertmacro MUI_LANGUAGE "Malay"
572 !insertmacro MUI_LANGUAGE "Mongolian"
573 !insertmacro MUI_LANGUAGE "Norwegian"
574 !insertmacro MUI_LANGUAGE "Polish"
575 !insertmacro MUI_LANGUAGE "Portuguese"
576 !insertmacro MUI_LANGUAGE "PortugueseBR"
577 !insertmacro MUI_LANGUAGE "Romanian"
578 !insertmacro MUI_LANGUAGE "Russian"
579 !insertmacro MUI_LANGUAGE "Serbian"
580 !insertmacro MUI_LANGUAGE "SerbianLatin"
581 !insertmacro MUI_LANGUAGE "SimpChinese"
582 !insertmacro MUI_LANGUAGE "Slovak"
583 !insertmacro MUI_LANGUAGE "Slovenian"
584 !insertmacro MUI_LANGUAGE "Spanish"
585 !insertmacro MUI_LANGUAGE "Swedish"
586 !insertmacro MUI_LANGUAGE "Thai"
587 !insertmacro MUI_LANGUAGE "TradChinese"
588 !insertmacro MUI_LANGUAGE "Turkish"
589 !insertmacro MUI_LANGUAGE "Ukrainian"
590 !insertmacro MUI_LANGUAGE "Welsh"
593 ;--------------------------------
596 ;These files should be inserted before other files in the data block
597 ;Keep these lines before any File command
598 ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
600 ReserveFile "NSIS.InstallOptions.ini"
601 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
603 ;--------------------------------
606 Section "-Core installation"
607 ;Use the entire tree produced by the INSTALL target. Keep the
608 ;list of directories here in sync with the RMDir commands below.
609 SetOutPath "$INSTDIR"
610 @CPACK_NSIS_FULL_INSTALL@
612 ;Store installation folder
613 WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
616 WriteUninstaller "$INSTDIR\Uninstall.exe"
618 Push "@CPACK_NSIS_DISPLAY_NAME@"
619 Call ConditionalAddToRegisty
620 Push "DisplayVersion"
621 Push "@CPACK_PACKAGE_VERSION@"
622 Call ConditionalAddToRegisty
624 Push "@CPACK_PACKAGE_VENDOR@"
625 Call ConditionalAddToRegisty
626 Push "UninstallString"
627 Push "$INSTDIR\Uninstall.exe"
628 Call ConditionalAddToRegisty
631 Call ConditionalAddToRegisty
633 !ifdef CPACK_NSIS_ADD_REMOVE
634 ;Create add/remove functionality
636 Push "$INSTDIR\AddRemove.exe"
637 Call ConditionalAddToRegisty
641 Call ConditionalAddToRegisty
644 ; Optional registration
646 Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
647 Call ConditionalAddToRegisty
649 Push "@CPACK_NSIS_HELP_LINK@"
650 Call ConditionalAddToRegisty
652 Push "@CPACK_NSIS_URL_INFO_ABOUT@"
653 Call ConditionalAddToRegisty
655 Push "@CPACK_NSIS_CONTACT@"
656 Call ConditionalAddToRegisty
657 !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
658 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
661 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
662 @CPACK_NSIS_CREATE_ICONS@
663 @CPACK_NSIS_CREATE_ICONS_EXTRA@
664 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
666 ; Write special uninstall registry entries
668 Push "$STARTMENU_FOLDER"
669 Call ConditionalAddToRegisty
670 Push "DoNotAddToPath"
671 Push "$DO_NOT_ADD_TO_PATH"
672 Call ConditionalAddToRegisty
673 Push "AddToPathAllUsers"
674 Push "$ADD_TO_PATH_ALL_USERS"
675 Call ConditionalAddToRegisty
676 Push "AddToPathCurrentUser"
677 Push "$ADD_TO_PATH_CURRENT_USER"
678 Call ConditionalAddToRegisty
679 Push "InstallToDesktop"
680 Push "$INSTALL_DESKTOP"
681 Call ConditionalAddToRegisty
683 @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
685 !insertmacro MUI_STARTMENU_WRITE_END
689 Section "-Add to path"
691 ;Read a value from an InstallOptions INI file
692 !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
693 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
694 !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
695 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
696 StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
701 ;--------------------------------
702 ; Create custom pages
703 Function InstallOptionsPage
704 !insertmacro MUI_HEADER_TEXT "Install Options" "Chose options for installing @CPACK_PACKAGE_INSTALL_DIRECTORY@"
705 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
709 ;--------------------------------
710 ; determine admin versus local install
717 UserInfo::GetAccountType
719 StrCmp $1 "Admin" 0 +3
720 SetShellVarContext all
721 ;MessageBox MB_OK 'User "$0" is in the Admin group'
723 StrCmp $1 "Power" 0 +3
724 SetShellVarContext all
725 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
729 ;Get installation folder from registry if available
735 ;--- Add/Remove callback functions: ---
736 !macro SectionList MacroName
737 ;This macro used to perform operation on multiple sections.
738 ;List all of your components in following manner here.
739 @CPACK_NSIS_COMPONENT_SECTION_LIST@
742 Section -FinishComponents
743 ;Removes unselected components and writes component status to registry
744 !insertmacro SectionList "FinishSection"
746 !ifdef CPACK_NSIS_ADD_REMOVE
747 ; Get the name of the installer executable
748 System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
751 ; Strip off the last 13 characters, to see if we have AddRemove.exe
754 StrCpy $R2 $R0 13 $R1
755 StrCmp $R2 "AddRemove.exe" addremove_installed
757 ; We're not running AddRemove.exe, so install it
758 CopyFiles $R3 $INSTDIR\AddRemove.exe
763 ;--- End of Add/Remove callback functions ---
765 ;--------------------------------
766 ; Component dependencies
767 Function .onSelChange
768 !insertmacro SectionList MaybeSelectionChanged
771 ;--------------------------------
775 ReadRegStr $START_MENU SHCTX \
776 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "StartMenu"
777 ;MessageBox MB_OK "Start menu is in: $START_MENU"
778 ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
779 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "DoNotAddToPath"
780 ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
781 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "AddToPathAllUsers"
782 ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
783 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "AddToPathCurrentUser"
784 ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
785 ReadRegStr $INSTALL_DESKTOP SHCTX \
786 "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" "InstallToDesktop"
787 ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
789 @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
791 ;Remove files we installed.
792 ;Keep the list of directories here in sync with the File commands above.
793 @CPACK_NSIS_DELETE_FILES@
794 @CPACK_NSIS_DELETE_DIRECTORIES@
796 !ifdef CPACK_NSIS_ADD_REMOVE
797 ;Remove the add/remove program
798 Delete "$INSTDIR\AddRemove.exe"
801 ;Remove the uninstaller itself.
802 Delete "$INSTDIR\Uninstall.exe"
803 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
805 ;Remove the installation directory if it is empty.
808 ; Remove the registry entries.
809 DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
811 ; Removes all optional components
812 !insertmacro SectionList "RemoveSection"
814 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
816 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
817 @CPACK_NSIS_DELETE_ICONS@
818 @CPACK_NSIS_DELETE_ICONS_EXTRA@
820 ;Delete empty start menu parent diretories
821 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
826 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
828 IfErrors startMenuDeleteLoopDone
830 StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
831 startMenuDeleteLoopDone:
833 ; If the user changed the shortcut, then untinstall may not work. This should
835 StrCpy $MUI_TEMP "$START_MENU"
836 Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
837 @CPACK_NSIS_DELETE_ICONS_EXTRA@
839 ;Delete empty start menu parent diretories
840 StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
842 secondStartMenuDeleteLoop:
845 GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
847 IfErrors secondStartMenuDeleteLoopDone
849 StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
850 secondStartMenuDeleteLoopDone:
852 DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
855 StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
856 Call un.RemoveFromPath
860 ;--------------------------------
861 ; determine admin versus local install
862 ; Is install for "AllUsers" or "JustMe"?
863 ; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
864 ; This function is used for the very first "custom page" of the installer.
865 ; This custom page does not show up visibly, but it executes prior to the
866 ; first visible page and sets up $INSTDIR properly...
867 ; Choose different default installation folder based on SV_ALLUSERS...
868 ; "Program Files" for AllUsers, "My Documents" for JustMe...
871 ; Reads components status for registry
872 !insertmacro SectionList "InitSection"
874 StrCpy $SV_ALLUSERS "JustMe"
875 StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
881 UserInfo::GetAccountType
883 StrCmp $1 "Admin" 0 +3
884 SetShellVarContext all
885 ;MessageBox MB_OK 'User "$0" is in the Admin group'
886 StrCpy $SV_ALLUSERS "AllUsers"
888 StrCmp $1 "Power" 0 +3
889 SetShellVarContext all
890 ;MessageBox MB_OK 'User "$0" is in the Power Users group'
891 StrCpy $SV_ALLUSERS "AllUsers"
895 StrCpy $SV_ALLUSERS "AllUsers"
896 ;Get installation folder from registry if available
899 StrCmp $SV_ALLUSERS "AllUsers" 0 +2
900 StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
902 StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
903 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"