Hi,
My application installs a few files in the %APPDATA% folder...but I would like to add a checkbox to give the user the option to install those files in my application folder (for people willing to do a "portable" installation.
How should I please proceed to implement the checkbox and set the conditions (if not checked install data files in appdata. If checked install those files in the app folder)
Thanks very much for your help!
Checkbox for custom installation
6 posts
You could use a section and let the user toggle it on the components page or you can create a custom page with nsDialogs...
Thanks for your quick reply!
Well unfortunately I don't know NSIS very well..so I'll take time to understand and implement what you propose me ;-)
How do I then set the files to be installed in a folder or another, based on the checkbox condition? (this being done on the next page)
Thanks!!
Well unfortunately I don't know NSIS very well..so I'll take time to understand and implement what you propose me ;-)
How do I then set the files to be installed in a folder or another, based on the checkbox condition? (this being done on the next page)
Thanks!!
You can do a custom page, like Anders said, in a callback function, you can define, what happens if the box is checked or what happens if the box is unchecked.
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
As I haven't seen your script, I don't know what you are already calling and what not.
Note that you must call some specific things, like:
Page custom MyPage CheckMyPage
Function MyPage
Var /GLOBAL MyDialog
Var /GLOBAL MyCheckbox
nsDialogs::Create 1018
Pop $MyDialog
${If} $MyDialog == error
Abort
${EndIf}
${NSD_CreateGroupBox} 0u 0u 300u 140u "Groupbox"
${NSD_CreateCheckBox} 5u 5u 220u 12u "My Checkbox Name"
Pop $MyCheckbox
SetCtlColors $MyCheckbox "0x000000" "transparent"
${NSD_SetState} $MyCheckbox ${BST_CHECKED}
nsDialogs::Show
FunctionEnd
Function CheckMyPage
Var /GLOBAL MyCheckbox_State
${NSD_GetState} $MyCheckbox $MyCheckbox_State
${If} $MyCheckbox_State = ${BST_CHECKED}
SetOutPath "C:\Blah"
File "text.txt"
${Else}
SetOutPath "$APPDATA\Blah"
File "text.txt"
${EndIf}
FunctionEnd
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
As I haven't seen your script, I don't know what you are already calling and what not.
Koopa,
Thanks so much for taking time to give me code line to study!
That's really appreciated!!
I now go and study that ;-) Thanks
Thanks so much for taking time to give me code line to study!
That's really appreciated!!
I now go and study that ;-) Thanks
Though, it's nothing more than raw example code. without seeing your script it's hard to help. And even using my code example requires some knowledge. I highly recommend, that you read the NSIS documentation, wiki etc. 🙂