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 aresilent
for silent mode andnormal
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