Archive: I need a little help with this script.


I need a little help with this script.
I'm using the following script to create an installer for my program.
The problem with this script is that it always sets the file association without asking permission.
Can some body help to change the script in such away that two checkboxes will be added
with the text:

"Associate my_program with the following file extensions"

[checkbox] .abc

[checkbox] .def

Here is the script:


; Script generated by the HM NIS Edit Script Wizard.

!include "registerExtension.nsh"

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "My Program"
!define PRODUCT_VERSION "1.00"
!define PRODUCT_PUBLISHER "XXXXXXX"
!define PRODUCT_WEB_SITE "http://XXXXXXXXX"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\my_program.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 "images\my_program.ico"
!define MUI_UNICON "images\my_program.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "license.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\my_program.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "setup_my_program.exe"
InstallDir "$PROGRAMFILES\EDFbrowser"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite on
File "release\my_program.exe"
; SetShellVarContext all
CreateShortCut "$DESKTOP\my_program.lnk" "$INSTDIR\my_program.exe"
CreateShortCut "$SMPROGRAMS\my_program.lnk" "$INSTDIR\my_program.exe"
File "doc\my_program_manual.html"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\my_program.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\my_program.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}"

${registerExtension} "$INSTDIR\my_program.exe" ".abc" "ABC files"
${registerExtension} "$INSTDIR\my_program.exe" ".def" "DEF files"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\my_program" "DisplayName" "my_program"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\my_program" "UninstallString" "$INSTDIR\uninst.exe"

System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\my_program_manual.html"
Delete "$INSTDIR\my_program.exe"

; SetShellVarContext all
Delete "$SMPROGRAMS\my_program.lnk"
Delete "$DESKTOP\my_program.lnk"

RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"

${unregisterExtension} ".abc" "ABC files"
${unregisterExtension} ".def" "DEF files"

DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\my_program"

; System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'

SetAutoClose true
SectionEnd


Thanks.

Please do not paste large amounts of code in the forums. Use pastebin or an attachment instead.

What you need to do is create a custom nsDialogs page. There is an excellent tutorial in the nsDialogs readme.