In my NSIS installer i have a custom function where the user has 2 Radio Buttons. Selecting the first one and clicking "Next" installs the software. Selecting the second one (Browse) and clicking "Next" displays an HTML file found on the installation medium.
Everything works but I would like to actually quit the installer when the user selects to browse option and the HTML page is displayed. Any idea how to do this?
In my custom page I have this:
${NSD_CreateRadioButton} 70 95 40% 6% "Install the Manuals to your PC"
Pop $hwnd
${NSD_AddStyle} $hwnd ${WS_GROUP}
${NSD_SetUserData} $hwnd "true"
${NSD_OnClick} $hwnd RadioClick
${NSD_CreateRadioButton} 70 175 40% 6% "Browse the $MEDIUM content"
Pop $hwnd
${NSD_SetUserData} $hwnd "false"
${NSD_OnClick} $hwnd RadioClick
I have a function that gets the data:
Function RadioClick
Pop $hwnd
${NSD_GetUserData} $hwnd $inst
FunctionEnd
And finally, a function that does the stuff with that data (start installation or browse):
Function post
${If} $inst == ""
MessageBox MB_OK "Please specify an option"
Abort
${ElseIf} $inst == false
ExecShell "open" "$EXEDIR\TechPubList_ForPC\$START_PUB"
Abort
${EndIf}
FunctionEnd
I need something to put in this last function after the "Abort" that actually quits the installer.
Any help is welcomed! Thank you!
Doesn't the Quit instruction do what you want? The manual states:
Causes the installer to exit as soon as possible. After Quit is called, the installer will exit (no callback functions will get a chance to run).
Related
I'm not able to understand what's wrong with the below code for jumping to particular offset if MessageBox returns IDNO.
Below code is to quit installer while IDNO is selected, but it always jumping to Goto endCurrentBlock line
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Would you like to continue installation?" IDNO +3
!insertmacro ShowStatus "Failed to install software"
Goto endCurrentBlock
Quit
If I use a absoule label for jump it's working good. What could be the reason?
Jumping by offset skips x number of NSIS instructions but !insertmacro is a preprocessor instruction that might expand to zero, one or several NSIS instructions.
It is not recommended to combine offset jumps and !insertmacro because it can break your code just by changing the macro...
Thanks for reading this.
I am making a program and I choose to package it using NSIS after getting disappointed by Inno.
I am trying to make a 2 steps install wizard. I could accomplish this by using Nsdialogs and a custom page.
Please see this image: here
Is it possible to change the "Install" button to became "I Agree" as in the license page?
and if this is possible, can this button be colored?
I have searched about this and I found some talk about a plugin called 'Buttonevent'. I download it and I saw the examples. AS I understood this can be used only to Add new buttons Not to change existing ones.
please help me if there is any clues.
That's a lot of code for a one-line solution. LicenseText is the attribute you are looking for. You should also consider using the license page as it is intended, too.
Page License
!include nsDialogs.nsh
Page Custom MyPageCreate
Page InstFiles
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
GetDlgItem $1 $hwndparent 1 ; Get handle to Install/Next button
${NSD_SetText} $1 "$(^AgreeBtn)"
nsDialogs::Show
FunctionEnd
Changing button colors is a lot of work and cannot be done in NSIS without a plugin...
I am new to NSIS so bear with me:
I am using NSIS (legacy code...) for making sure that .NET is installed before launching a .NET application.
If it is not installed, I am installing it for the user, but I would prefer getting user's approval before playing hooky with his system.
I was able to display the message to the user:
using this code:
WriteIniStr $MissingItemsIniFilename 'Field 2' 'State' '$R2'
WriteIniStr $MissingItemsIniFilename 'Settings' 'CancelEnabled' 1
InstallOptions::Dialog $MissingItemsIniFilename
Pop $1 ;get button action
my problem is that after user clicks Next the "dialog" is not closing and shows:
So my question is, How can I close the dialog?
Extra information:
I am using InstallOptions for showing the dialog.
I looked into nsDialogs but could not find there a solution that worked for me (might be due to lack of experience in NSIS).
Please let me know if any other information is required...
If you want to hide the entire installer you can do:
HideWindow
ExecWait ...
BringToFront
otherwise you should probably move that ExecWait to a Section...
page custom test
# Installer sections
Section -Main SEC0000
SetOutPath $INSTDIR
MessageBox MB_OK "done"
;............
;.........
SectionEnd
Function test
MessageBox MB_OK "ok"
//Do some stuff
FunctionEnd
# Installer functions
Function .onInit
!ifdef IsSilent
SetSilent silent
!endif
InitPluginsDir
FunctionEnd
In the above code run both ways silent and non-silent mode. If you run it in non-silent mode [user interaction], custom page function is called and msg box displayed. But if you run it in silent mode[no user interaction], then the custom page is not called and no msg box is displayed. Also, done msg box was displayed in the silent mode.
Is there any reason the custom page isn't called in silent installer?
How to call custom page in silent installer mode?
Is there any reason is there the custom page did not call in silent installer?
It is by design: a silent installer is silent, i.e. it displays no GUI thus no page is shown (neither standard nor custom) and no page callback is triggered. MessageBox is special as it is mapped to the standard function and was triggered by you.
How to call custom page in silent installer mode?
You cannot. If you have some processing in the custom page, put it in a function:
that will be called from the custom page
that will be called explicitly from either the .onInit or a section with something like
IfSilent 0 +2
Call YourProcessingFunc
If you are basing the processing on some choices given by the user in the custom page, you need to use some defaults in silent mode. Or to implement a parameter passing by the command line.
In an NSIS MUI script it is possible to make a section compulsory by adding "SectionIn RO" to the section. I would like to specify that the entire SectionGroup is compulsory. I know I can make each of the individual components compulsory which makes the group compulsory by default, but the SectionGroup checkbox is still enabled indicating that the user can turn it off. This could be confusing.
Is there an equivilent to "SectionIn RO" for SectionGroups and thus force the group's checkbox to be disabled?
I would say this is a NSIS bug. (If you decide to report this on the project tracker, you can reference this bug, it should have been fixed as part of that bug)
Forcing the readonly flag seems to work:
SectionGroup /e foo SecFoo
Section bar
SectionIn RO
SectionEnd
Section baz
SectionIn RO
SectionEnd
SectionGroupEnd
page components "" ForceHackyRO
page InstFiles
!include Sections.nsh
Function ForceHackyRO
!insertmacro SetSectionFlag ${SecFoo} ${SF_RO}
FunctionEnd