NSIS auto accept dialog in silent mode - nsis

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:

Related

Simulate Standard Windows Popup message Beep sound

I would like to simulate the standard windows popup message Beep sound in order to have each popup message in my script with the same sound effect.
In my script I use the default clause MUI_ABORTWARNING so, when the relative popup message is displayed, the standard windows popup message Beep is played.
For my purpose, I tryed to use the following API call but the sound effect is very different
System::Call "kernel32::Beep(i, i) b (${BEEP_FREQ_HZ}, ${BEEP_DURATION_MSEC})"
How can I do to accomplish the task?
Many thanks in advance to everyone that can help me on this.
Regards,
kernel32::Beep tries to use the little hardware speaker in your machine, if not available it uses the default system sound.
Use MessageBeep to generate a standard sound:
!define /IfNDef MB_ICONWARNING 0x00000030 ; You might want MB_ICONINFORMATION or MB_ICONSTOP instead
System::Call 'USER32::MessageBeep(i ${MB_ICONWARNING})'
If you are actually calling MessageBox in your NSIS code then you don't need to call MessageBeep, MessageBeep will be called for you if you use one of the MB_ICON* flags.

NSIS: How to distinguish between Cancel and Close button

In NSIS, on a custom page, I want to skip the page when the user presses the Cancel button, but I want to exit the installer (with confirmation) when the user presses the window's X button. How do I do that?
Currently, by using Modern UI and custom abort function, I get the same function called regardless of which of the two buttons is pressed.
This is not normal installer behavior and I would not recommend that you try to implement this.
If you still want to try I guess it might be possible with the ButtonEvent plug-in or the WndSubclass plug-in...

How to call custom page function in silent installer using 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.

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.

Cancelling an InnoSetup installer

Situation
During the installation of our product I detect if our programs are still running (from a previous installation) by using CheckForMutexes. If our programs are still running I pop up a message box (by using MsgBox) that tells the user to close the programs. If the user clicks the ok and they haven't closed our programs, the same message box is displayed. I'd like to display a cancel button in the MsgBox that aborts the installation, which would be desired in the case the user doesn't want to close the running programs.
Question
How can I abort an InnoSetup install programmatically?
Thanks in advance
Take a look at InitializeSetup and Abort in the Inno Setup help. The Abort function will allow the setup to exit.
Call the WizardForm.Close() method.
It will prompt the user if she really wants to cancel the installation.
procedure ExitSetup;
begin
WizardForm.Close;
end;

Resources