Question

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  
Was it helpful?

Solution

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

  • /S runs the installer or uninstaller silently
  • /D sets the default installation directory ($INSTDIR), overriding InstallDir and InstallerDirRegKey. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. Only absolute paths are supported.

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 
  • If some information should be gathered from user in silent mode, some more options can be passed to function .onInit with GetOptions,

like here:

!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions

Function .onInit
  ${GetParameters} $R0
  ClearErrors
  ${GetOptions} $R0 /USERNAME= $0
FunctionEnd

References

NSIS silent install 1

NSIS silent install 2

NSIS silent install 3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top