How to make a Nullsoft Scriptable Install System (NSIS) installer silent?
From Wikipedia:
"Nullsoft Scriptable Install System (NSIS), est un logiciel libre contrôlable par script, qui permet la création d'installateurs pour Windows. Il a été initialement développé par Nullsoft, la société créatrice de Winamp. NSIS est une alternative aux produits commerciaux, comme InstallShield.
The NSIS compiler program makensis compiles scripts like the following example into executable installation programs. Each line in the script contains a single command."
# Example script
Name "Example1"
OutFile "example1.exe"
InstallDir "$PROGRAMFILES\Example1"
Page Directory
Page InstFiles
Section
SetOutPath $INSTDIR
File ..\makensis.exe
SectionEnd
Command line usage
1. MakeNSIS usage
Compile a NSIS (.nsi) script o generate installer
makensis [option | script.nsi | - [...]]
Example
makensis.exe myscript.nsi
2. Installer usage
Some options
Examples
installer.exe /S
installer.exe /S /D=C:\Program Files\NSIS
Silent installers / uninstallers
To check whether installer is silent, use IfSilent
To skip some insructions in silent mode (user interaction, creation of window), use jump instruction
Example
IfSilent +2 0
MessageBox MB_OK|MB_ICONINFORMATION 'This is a "non silent" installer'
In this example, message box is displayed iif installer is silent. +2
means that nex instruction is skipped if IfSilent is true. 0
means hat compiler should go to next instruction if IfSilent is false.
To set an installer in silent mode (just for a while), use SetSilent
in .onInit
method. Options are silent
for silent mode and normal
for non silent mode.
To set installer | unsinstaller silent, you can also use
SilentInstall silent
SilentUnInstall silent
In silent mode, all screens from installer itself are not displayed. However, message boxes and all other screens not flagged with SF_SELECTED may be displayed. To make installer fully silent, use either instruction jump (in general), or flag /SD IDOK | IDCANCEL (for OK|CANCEL messsage boxes).
MessageBox MB_OK|MB_ICONINFORMATION "This is not a silent installer" /SD IDOK
Here, if silent mode is on, message box is not displayed and behaves as with user OK. Beware of the options order there
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "Application is running. Please close it first." /SD IDCANCEL IDOK OK IDCANCEL CANCEL
like here:
!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions
Function .onInit
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 /USERNAME= $0
FunctionEnd
References