Archive: Optionally creating desktop shortcuts?


Optionally creating desktop shortcuts?
Is there an example of a script that lets the user check a checkbox during install that determines if desktop shortcuts get created? I'd like to create these shortcuts, but only if the user wants them to be created.

Thanks,

Kennedy


Make a custom page or add a component to your components page (Section).

Stu


Some code snippets
Hi,

I wrote this function for use as custom page.


Function ShortcutPage

; Prepare shortcut page with default values
!insertmacro MUI_HEADER_TEXT "Additional Shortcuts" "Please select, whether additional shortcuts should be created."

; Display shortcut page
!insertmacro INSTALLOPTIONS_DISPLAY_RETURN "ShortcutPage.ini"
pop $R0

${If} $R0 == "cancel"
Abort
${EndIf}

; Get the selected options
ReadINIStr $R1 "$PLUGINSDIR\ShortcutPage.ini" "Field 3" "State"
ReadINIStr $R2 "$PLUGINSDIR\ShortcutPage.ini" "Field 4" "State"

${If} $R1 == "1" ; Did user check create desktop shortcut?
CreateShortCut "$DESKTOP\$(TEXT_DESKTOP_LINK)" "$INSTDIR\${PRODUCT_EXE}"
${EndIf}

${If} $R2 == "1" ; Did user check create quick launch shortcut?
CreateShortCut "$QUICKLAUNCH\$(TEXT_DESKTOP_LINK)" "$INSTDIR\${PRODUCT_EXE}"
${EndIf}

FunctionEnd



In your script you have to call this function like this:


Page custom ShortcutPage


You need the ShortcutPage.ini file with the following entry:

[Settings]
NumFields=4
[Field 1]
Type=label
Text=Setup can create shortcuts on your Desktop and in the Quick Launch bar for easier access.
Left=0
Right=-1
Top=5
Bottom=25

[Field 2]
Type=label
Text=Please select the shortcuts, which are to be created by the setup:
Left=0
Right=-1
Top=35
Bottom=45


[Field 3]
Type=checkbox
Text=Yes, I would like to create the shortcut on the Desktop.
Left=15
Right=-1
Top=55
Bottom=65
State=1

[Field 4]
Type=checkbox
Text=Yes, I would like to create the shortcut in the &Quick Launch bar.
Left=15
Right=-1
Top=75
Bottom=85
State=1


I hope this will help you to create your own custom page to create addional short cuts.

Mikesch