Archive: CreateShortCut to the selected sections


CreateShortCut to the selected sections
My program have 6 section. How can I CreateShortCut to the sections which have been selected by the users.
If there is and you know it, just let me know.
Thanks.


This should get you started.


# Create the directory for the shortcuts.
SetOutPath "$SMPROGRAMS\Your Main Folder Name}"

!insertmacro SectionFlagIsSet Your_Section_Name ${SF_SELECTED} 0 +6
# This will set the "Start In" directory.
SetOutPath "$ApplicationDir\Your_Directory"
CreateShortCut "$SMPROGRAMS\Your Main Folder Name\Your_applciation_Name.lnk" \
"$INSTDIR\Your_Application_directory\Your_EXE"

!insertmacro SectionFlagIsSet Your_Section_Name2 ${SF_SELECTED} 0 +6
# This will set the "Start In" directory.
SetOutPath "$ApplicationDir\Your_Directory2"
CreateShortCut "$SMPROGRAMS\Your Main Folder Name2\Your_applciation_Name2.lnk" \
"$INSTDIR\Your_Application_directory2\Your2_EXE"

thank you very much!
I will have a try.


This code do not work well.
The shortcut will allways be created,no matter the section selected or not.
I don't know why, the code seem right. where can I know more about "!insertmacro SectionFlagIsSet"


Did you define your sections like this?

Section "My Section Name" SecID1


I want to CreateShortCut to the sections which have been checked by the users,
but the code does not work well.
The shortcut will allways be created,no matter the section checked or not.

My chortcut.nsi is here


Sorry, I screwed up the example. This works.



section ""
# Create the directory for the shortcuts.
SetOutPath "$SMPROGRAMS\CreateShortCut"

!insertmacro SectionFlagIsSet "${sec1}" "${SF_SELECTED}" 0 skipRed
CreateShortCut "$SMPROGRAMS\CreateShortCut\red.lnk" "$INSTDIR\red.html"
skipRed:
!insertmacro SectionFlagIsSet "${sec2}" "${SF_SELECTED}" 0 skipBlue
CreateShortCut "$SMPROGRAMS\CreateShortCut\blue.lnk" "$INSTDIR\blue.html"
skipBlue:
!insertmacro SectionFlagIsSet "${sec3}" "${SF_SELECTED}" 0 skipGreen
CreateShortCut "$SMPROGRAMS\CreateShortCut\green.lnk" "$INSTDIR\green.html"
skipGreen:
!insertmacro SectionFlagIsSet "${sec4}" "${SF_SELECTED}" 0 skipGray
CreateShortCut "$SMPROGRAMS\CreateShortCut\gray.lnk" "$INSTDIR\gray.html"
skipGray:
SectionEnd

Don't say sorry, you are so kind! The code really work very well!
Thank you very much!