Archive: add macro in MUI_PAGE_DIRECTORY


add macro in MUI_PAGE_DIRECTORY
Hello,
it's my first time with nsis, and i have this installer and i'd like to add a macro for remove a directory when the user uninstall the software.
What should i do to add in Direcotry Page a checkbox to save this information?
How can i do to inform the uninstall that it has to delete the directory?



thx

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Thinware Remote Management"
!define PRODUCT_VERSION "beta1 (0.6-0)"
!define PRODUCT_PUBLISHER "Thinware s.r.l."
!define PRODUCT_WEB_SITE "http://www.thinware.it"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\trm.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
;
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_TITLE_3LINES

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
!insertmacro MUI_PAGE_WELCOME

; License page
!insertmacro MUI_PAGE_LICENSE "licenza.txt"

;
!insertmacro MUI_PAGE_DIRECTORY

; Instfiles page
!insertmacro MUI_PAGE_INSTFILES

; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\trm.exe"
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Thinware_Remote_Management__Manuale_Utente.pdf"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Italian"

; MUI end ------


Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\Thinware Remote Management"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Section "SezionePrincipale" SEC01
;
; general
;
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
CreateDirectory "$SMPROGRAMS\Thinware Remote Management"
CreateShortCut "$SMPROGRAMS\Thinware Remote Management\Thinware Remote Management.lnk" "$INSTDIR\trm.exe"
CreateShortCut "$SMPROGRAMS\Thinware Remote Management\Thinware Remote Management Manuale Utente.lnk" "$INSTDIR\Thinware_Remote_Management__Manuale_Utente.pdf"
CreateShortCut "$DESKTOP\Thinware Remote Management.lnk" "$INSTDIR\trm.exe"
File "..\bin_win32\trm.exe"
File "..\.obj\trm.intermediate.manifest"
File "..\docs\manuale_utente\Thinware_Remote_Management__Manuale_Utente.pdf"
;
; help
;
SetOutPath "$INSTDIR\help\en_us"
File /r "..\help\en_us\*.html"
SetOutPath "$INSTDIR\help\it"
File /r "..\help\it\*.html"
;
;translations
;
SetOutPath "$INSTDIR\translations"
File /r "..\translations\trm_*.qm"
SectionEnd

Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\Thinware Remote Management\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\Thinware Remote Management\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\trm.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\trm.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) �stato completamente rimosso dal tuo computer."
FunctionEnd

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Sei sicuro di voler completamente rimuovere $(^Name) e tutti i suoi componenti?" IDYES +2
Abort
FunctionEnd

Section Uninstall
;
; general
;
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Thinware_Remote_Management__Manuale_Utente.pdf"
Delete "$INSTDIR\trm.exe"
Delete "$INSTDIR\trm.intermediate.manifest"
;
; help
;
RMDir /r "$INSTDIR\help"
RMDir /r "$INSTDIR\translations"

Delete "$SMPROGRAMS\Thinware Remote Management\Uninstall.lnk"
Delete "$SMPROGRAMS\Thinware Remote Management\Website.lnk"
Delete "$SMPROGRAMS\Thinware Remote Management\Thinware Remote Management Manuale Utente.lnk"
Delete "$DESKTOP\Thinware Remote Management.lnk"

Delete "$SMPROGRAMS\Thinware Remote Management\Thinware Remote Management.lnk"

RMDir "$SMPROGRAMS\Thinware Remote Management"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd

any hint or examples? i searched for on google but i have not found good suggesition...


maybe you should try a custom page in the installer and then you could write a config file to the install dir and while installing you could perforam a simple loop to remove all those directories


ok, i'ill try, and if i want to show just simple popup that ask if the user want to remove the directory too, what should i do to do it?


try a messagebox and if he/she clicks yes then remove it


thx so much...i've found this:

  Function un.onUninstSuccess
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Remove directory?" IDYES +2
FunctionEnd


but how can i do to call a function if the user pressed ok button?

Call Function_Name


i found this script:
check here
http://nsis.sourceforge.net/Common_I...ponents_Choise
maybe it can be helpful if i want to add a check box to allow the user to delete some directories during uninstall process...but it's my first time with nsis and i have some problem to understand how it work, for example:
who's going to call the function .onSelChange?
What should i do to put the checkbox in my MUI_PAGE_DIRECTORY? And above all, is it possible?
thx so much for your support.


i did some test with this macro:


Page custom a ;Custom page
!insertmacro MUI_PAGE_COMPONENTS

where "a" is my function to load field into the macro, but it is not that i'm looking for...i'd like to create a my personal page with a textfield and a checkbox, of course next and previous buttons too.
any hint?
thx

to create a customised page try InstallOptions or nsDialogs. they are included with nsis and u can have a look at the examples in the examples directory