- NSIS Discussion
- Making Desktop Shortcut Optional
Archive: Making Desktop Shortcut Optional
JWood
4th April 2005 03:25 UTC
Making Desktop Shortcut Optional
I have a very simple script generated by the HM NIS Wizards (no selectable components or anything like that).
I works well but I would like the creation of a desktop shortcut to be optional. Right now, it creates a desktop shortcut, which I like. But the user should have the choice of not creating one.
Does anyone have some simple code for making this process optional?
Thanks.
Jonathan
hesung
4th April 2005 05:23 UTC
Add one Section to be selected..
Section /o "Wanna a destop shortcut"
CreateShortCut "$DESKTOP\ShortcutName.lnk" "$INSTDIR\AimName.exe"
SectionEnd
;;---If the user wanna one, he|her can selete it.
I don't think using HM NIS Wizards is a good idea..The simple is too simple..
hesung
4th April 2005 05:34 UTC
Donnot forget to insert this Page Macro in the Page Options
!insertmacro MUI_PAGE_COMPONENTS
If using the HM_NIS you can select the Checkbox"Allow user to select the componnents to install" to add the code
......
Then add the section.
JWood
4th April 2005 21:31 UTC
Thanks, but then the user has the option of not installing the main program files. Also, I really don't care for the layout of the page where you select components. It it hard to add an option or a new page with an option to install the desktop shortcut?
Thanks.
glory_man
5th April 2005 10:16 UTC
Thanks, but then the user has the option of not installing the main program files.
You can set "read-only"-attrib for section (include SectionIn R0 inside section) -> user won't be able to change its state.
Or you can create checkbox on finishpage named "Create desktop shortcut". Example for MUI may be like this:
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_RUN_FUNCTION "myfunction"
Function "myfunction"
CreateShortCut "$DESKTOP\My_programm.lnk" "$INSTDIR\proga.exe"
FunctionEnd
glory_man
5th April 2005 10:49 UTC
And question by this thread.
The SectionIn RO works but doesn't look right for me.
Why not?
This code will also help you to show the "main programm files"-section as enabled but the user will not be able to modify its state (without setting "read-only"-attrib for section).
Function .onSelChange
SectionGetFlags ${SecIndex} $R0
IntOp $R1 $R0 & 0x0001
IntCmp $R0 1 sekok
IntOp $R1 $R0 | 0x0001
SectionSetFlags ${SecIndex} $R1
sekok:
FunctionEnd
JWood
5th April 2005 19:39 UTC
Yeah, I think it might look better not being grayed out. However, it still seems funky to me have a screen that asks the user to choose program elements to install and there are only two items, and only one of those items can be modified, and that item doesn't really relate to installing program elements.
From a user-interface standpoint, it seems that it would be far more reasonable to simply display a single checkbox that specifies if a desktop shortcut should be created.
There may be different opinions but I've been programming a long time and that's my opinion.
I'm trying to figure out how to add the checkbox but the docs are seeming pretty lean to me. (Neither custom nor InstallOptions are even in the help index.)
Thanks.
Afrow UK
5th April 2005 19:58 UTC
Read glory_man post 3 posts up.
He has attached code to add a "Create desktop shortcut" check-box to the MUI Finish page.
-Stu
JWood
5th April 2005 20:26 UTC
Originally posted by Afrow UK
Read glory_man post 3 posts up.
He has attached code to add a "Create desktop shortcut" check-box to the MUI Finish page.
-Stu
Could I get some sort of clue as to which post you are referring to. I'm using my browser to view these posts. As soon as you replied, this thread went to the top of the list so there is no "3 posts up."
And I couldn't find anything with a subject similar to "add a "Create desktop shortcut" check-box to the MUI Finish page."
Sounds like just what I need. Something to go on? Please.
Pidgeot
5th April 2005 22:36 UTC
A post is not the same as a thread. When Afrow says "3 posts up", he means 3 posts above his in this thread.
The code he's referring to is this:
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_RUN_FUNCTION "myfunction"
Function "myfunction"
CreateShortCut "$DESKTOP\My_programm.lnk" "$INSTDIR\proga.exe"
FunctionEnd
If you need MUI_FINISHPAGE_RUN for something else, you can use a messagebox:
MessageBox MB_YESNO|MB_ICONQUESTION "Create desktop shortcut?" IDNO +2
CreateShortCut "$DESKTOP\My Program.lnk" "$INSTDIR\program.exe"
Place it in an appropriate section of your installer.
JWood
5th April 2005 23:01 UTC
Originally posted by Pidgeot
A post is not the same as a thread. When Afrow says "3 posts up", he means 3 posts above his in this thread.
Doh! How right you are. My apologies to both you and "Afrow UK". I'm used to using Outlook Express for this type of stuff and just missed those comments.
Thanks!
JWood
5th April 2005 23:02 UTC
Originally posted by glory_man
Or you can create checkbox on finishpage named "Create desktop shortcut". Example for MUI may be like this:
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_RUN_FUNCTION "myfunction"
Function "myfunction"
CreateShortCut "$DESKTOP\My_programm.lnk" "$INSTDIR\proga.exe"
FunctionEnd
[/B]
I apologize for completely missing these comments the first time around. I've got this code working and just trying to decide if that's the way I'll go. Either way, it was an excellent suggestion. Thanks a million!
glory_man
6th April 2005 10:14 UTC
As I can see JWood uses MUI_FINISHPAGE_RUN. So defines-code can be modified to the next:
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION "myfunction"