How to call custom page function in silent installer using NSIS? - nsis

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.

Related

NSIS -- Customize existing button?

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...

How to disable close button in the ABORT Message box in nsis?

I have used nsi script for creating exe file.In the installation steps I have one message box which shows confirmation dialog box if user wants to cancel the installation.
!define MUI_ABORTWARNING "Are you sure want to abort the installation"
It produces following message box:
In this message box contains disable x close button in the above of the messagebox.now i want to remove that [x] close button.
[or]
Is there any other message box is available to do this job?
NSIS uses the normal MessageBox and that only allows you control the buttons. Close means cancel/no/abort and this is normal windows behavior...
To change this you would need to implement a custom dialog and recompile NSIS.

NSIS auto accept dialog in silent mode

I have an nsis installer with a custom dialog within that has an Accept button but when i run it in silent mode , it does not accept the dialog. How to make it auto clicking accept silently?
If your dialog was a standard MessageBox, simply add the /SD button_id_to_use parameter to the MessageBox instruction to tell NSIS what is the choice to use in silent mode:
MessageBox MB_YESNO "Accept?" /SD IDNO IDNO Skipped
if your dialog is a custom page, the problem is that in silent mode, no pages are involved at all (even hidden), and no page callback are trigerred. You need to check IfSilent and call the logic that is triggered by the Accept button separately from either the .onInit or a section.
IfSilent Accepted
MessageBox MB_YESNO "Accept?" IDNO Skipped
Accepted:
// some code when accepted
Skipped:

Possible to hide all details in NSIS installation progress page?

Using the Nullsoft Scriptable Install System (NSIS), I'm looking for a way to hide the details on the MUI_PAGE_INSTFILES page when having a setup with Modern UI 2.
Currently an example of what I have is this:
And this would be what I want to achieve:
(German only, sorry)
As you see, there is no information about the individual file being copied as well as no way to show the details.
I've searched the documentation of Modern UI 2 but found no function to call to make these two controls (label and button) hidden.
My question is:
Is there a way to hide the file label and the details button that are being shown during a setup installation progress?
Solved
With the help of Anders, I've managed to do what I want:
First, I put
ShowInstDetails nevershow
ShowUninstDetails nevershow
at the top of my NSI file. Next, I put
SetDetailsPrint none
inside at the beginning of the Section "All files" section, and I put
SetDetailsPrint none
inside at the beginning of the Section "Uninstall" section.
Both, my setup and my uninstaller now runs without showing details.
ShowInstDetails nevershow + SetDetailsPrint none
ShowInstDetails nevershow
Section
SetDetailsPrint none
SectionEnd

How to make a SectionGroup mandatory in NSIS script

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

Resources