Previous (MakeNSIS Usage) | Index | Next (Compile Time Commands)


Chapter 4 - Scripting Reference




4.1 Script File Format
A NSIS Script File (.nsi) is just a text file with a series of commands.
MessageBox MB_OK "I'll be happy" ; this one puts a ' inside a string
          MessageBox MB_OK 'And he said to me "Hi there!"' ; this one puts a " inside a string
          MessageBox MB_OK `And he said to me "I'll be fucked!"` ; this one puts both ' and "s inside a string
          MessageBox MB_OK "$\"A quote from a wise man$\" said the wise man" ; this one shows escaping of quotes
CreateShortCut "$SMPROGRAMS\NSIS\ZIP2EXE project workspace.lnk" \
                         "$INSTDIR\source\zip2exe\zip2exe.dsw"
          MessageBox MB_YESNO|MB_ICONQUESTION \
                     "Remove all files in your NSIS directory? (If you have anything \
                     you created that you want to keep, click No)" \
                     IDNO NoRemoveLabel



4.2 Variables
All variables are global and can be used in Sections or Functions. Variables are case sensitive.


4.2.1 User Variables
$VARNAME User variables can be declared with the
Var command. You can use these variables to store values, work with string manipulation etc.


4.2.1.1 Var
var_name
Declare a user variable. Allowed characters for variables names: [a-z][A-Z][0-9] and '_'.


4.2.2 Other Writable Variables
$0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $R0, $R1, $R2, $R3, $R4, $R5, $R6, $R7, $R8, $R9 Registers. These variables can be used just like user variables, but are usually used in shared functions or macro's. You don't have to declare these variables, so you won't get any name conflicts when using them in shared code. When using these variables in shared code, it's recommended that you use the stack to save and restore their original values. These variables can also be used for communication with plug-ins, because they can be read and written by the plug-in DLL's. $INSTDIR The installation directory ($INSTDIR is modifiable using
StrCpy , ReadRegStr , ReadINIStr , etc. - This could be used, for example, in the .onInit function to do a more advanced detection of install location). $OUTDIR The current output directory (set implicitly via SetOutPath or explicitly via StrCpy , ReadRegStr , ReadINIStr , etc) $CMDLINE The command line of the installer. The format of the command line can be one of the following: $LANGUAGE The identifier of the language that is currently used. For example, English is 1033. You can change this variable in .onInit.


4.2.3 Constant Variables
Constant variables can also be used in the
InstallDir attribute. $PROGRAMFILES The program files directory (usually C:\Program Files but detected at runtime). $DESKTOP The windows desktop directory (usually C:\windows\desktop but detected at runtime). The context of this variable (All Users or Current user) depends on the SetShellVarContext setting. The default is the current user. $EXEDIR The location of the installer executable. (technically you can modify this variable, but it is probably not a good idea) ${NSISDIR} A symbol that contains the path where NSIS is installed. Detected at compile time. Useful if you want to call resources that are in NSIS directory e.g. Icons, UI's... $WINDIR The windows directory (usually C:\windows or C:\winnt but detected at runtime) $SYSDIR The windows system directory (usually C:\windows\system or C:\winnt\system32 but detected at runtime) $TEMP The system temporary directory (usually C:\windows\temp but detected at runtime) $STARTMENU The start menu folder (useful in adding start menu items using CreateShortCut ). The context of this variable (All Users or Current user) depends on the SetShellVarContext setting. The default is the current user. $SMPROGRAMS The start menu programs folder (use this whenever you want $STARTMENU\Programs). The context of this variable (All Users or Current user) depends on the SetShellVarContext setting. The default is the current user. $SMSTARTUP The start menu programs / startup folder. The context of this variable (All Users or Current user) depends on the SetShellVarContext setting. The default is the current user. $QUICKLAUNCH The quick launch folder for IE4 active desktop and above. If quick launch is not available, simply returns the same as $TEMP. $HWNDPARENT The decimal HWND of the parent window. $PLUGINSDIR The path to a temporary folder created upon the first usage of a plugin or a call to InitPluginsDir . This folder is automatically deleted when the installer exits. This makes this folder the ideal folder to hold INI files for InstallOptions , bitmaps for the splash plugin, or any other file that a plugin needs to work.


4.2.4 Variables Used in Strings
$$ Use to represent $. $\r Use to represent a carriage return (\r). $\n Use to represent a newline (\n). $\t Use to represent a tab (\t). ${SYMBOL} Where SYMBOL is the name of something globally defined, this will be replaced with the value of that symbol. The order of calling Symbols in the script is important.
Name "Test Program ${VERSION}"
!define VERSION "V.1.0"
This code will set the name of the installer to "Test Program ${VERSION}". The Same happens if the Symbol has not been defined.
!define VERSION "V.1.0"
Name "Test Program ${VERSION}"
This code sets the name of the installer to "Test Program V.1.0"
For more info, see
Conditional Compilation .


4.3 Labels
Labels are the targets of Goto instructions, or of the various branching instructions (such as
IfErrors , MessageBox , IfFileExists , and StrCmp ). Labels must be within a Section or a Function. Labels are local in scope, meaning they are only accessible from within the Section or Function that they reside in.
To declare a label, simply do: MyLabel: Labels cannot begin with a -, +, !, $, or 0-9. When specifying labels for the various instructions that require them, remember that both an empty string ("") and 0 both represent the next instruction (meaning no Goto will occur). Labels beginning with a period (.) are global, meaning you can jump to them from any function or section (though you cannot jump to an uninstall global label from the installer, and vice versa).


4.4 Relative Jumps
Unlike labels, relative jumps are, as the name suggests, relative to the place they are called from. You can use relative jumps wherever you can use labels. Relative jumps are marked by numbers. +1 jumps to the next instruction (the default advancement), +2 will skip one instruction and go to the second instruction from the current instruction, -2 will jump two instructions backward, and +10 will skip 9 instructions, jumping to the tenth instruction from the current instruction.
An instruction is every command that is executed at run-time, when the installer is running.
MessageBox , Goto , GetDLLVersion , FileRead , SetShellVarContext are all instructions. AddSize , Section , SubSection , SectionEnd , SetOverwrite (and everything under Compiler Flags ), Name , SetFont , LangString , are not instructions because they are executed at compile time.
Examples:
Goto +2
   MessageBox MB_OK "You will never ever see this message box"
 MessageBox MB_OK "The last message was skipped, this one should be shown"
 Goto +4
 MessageBox MB_OK "The following message will be skipped"
 Goto +3
 MessageBox MB_OK "You will never ever see this message box"
 Goto -3
 MessageBox MB_OK "Done"
<b>Note:</b> relative jumps don't work with Exch , File , Plugin DLLs , InitPluginsDir , GetFileTimeLocal or GetDLLVersionLocal . Do not try to jump over them using relative jumps, you will not get the result you were expecting.


4.5 Pages
Each (non-silent) NSIS installer has a set of pages. Each page can be a NSIS built-in page or a custom page created by a user's function (with
InstallOptions for example).
Using the script you can control the pages' order, appearance, and behavior. You can skip pages, paint them white, force the user to stay in a certain page until a certain condition is met, show a readme page, show custom designed pages for input and more. In this section, you will learn how to control all of the above.
There are two basic commands regarding pages, Page and UninstPage . The first adds a page to the installer, the second adds a page to the uninstaller. On top of those two there is the PageEx command which allows you to add a page to either one and with greater amount of options. PageEx allows you to set options to the specific page you are adding instead of using the default that's set outside of PageEx .


4.5.1 Ordering
The page order is set simply by the order
Page , UninstPage and PageEx appear in the script. For example:
Page license
 Page components
 Page directory
 Page instfiles
 UninstPage uninstConfirm
 UninstPage instfiles
This code will tell NSIS to first show the license page, then the components selection page, then the directory selection page and finally the install log where sections are executed, just like in old installers. The uninstaller will first show the uninstall confirmation page and then the uninstallation log.
You can specify the same page type more than once.
If you don't use any page command the installer's pages order will be just as in older versions: license (if LicenseText and LicenseData were specified), components (if ComponentText was specified and there is more than one visible section), directory (if DirText was specified) and instfiles. The uninstaller's pages order will be: uninstall confirmation page (if UninstallText was specified) and instfiles.


4.5.2 Page Options
Each page has its unique set of data that defines how it will look and act. This section describes what data each type of page uses and how you can set it.
Callbacks are described below and are not dealt with in this section.
The list below lists what commands affect the certain page type. Unless mentioned otherwise, these commands can be used both in and out of a PageEx block. If used inside a PageEx block they will only affect the current page being set by PageEx , else they will set the default for every other page. License page Components selection page Directory selection page Un/Installation log page Uninstall confirmation page To set the page caption use Caption .


4.5.3 Callbacks
Each built-in page has three callback functions. The pre-function, the show-creation function and the leave-function. The pre-function is called right before the page is created, the show-function is called right after it is created and before it is shown and the leave-function is called right after the user has pressed the next button and before the page is left.
A custom page only has two callback functions, one that creates it which is mandatory, and one leave-function that acts just like the leave-function for built-in pages.
Examples:
Page license skipLicense "" stayInLicense
 Page custom customPage "" ": custom page"
 Page instfiles
 Function skipLicense
   MessageBox MB_YES "Do you want to skip the license page?" IDNO no
     Abort
   no:
 FunctionEnd
 Function stayInLicense
   MessageBox MB_YES "Do you want to stay in the license page?" IDNO no
     Abort
   no:
 FunctionEnd
 Function customPage
   GetTempFileName $R0
   File /oname=$R0 customPage.ini
   InstallOptions::dialog $R0
   Pop $R1
   StrCmp $R1 "cancel" done
   StrCmp $R1 "back" done
   StrCmp $R1 "success" done
   error: MessageBox MB_OK|MB_ICONSTOP "InstallOptions error:$\r$\n$R1"
   done:
 FunctionEnd



4.5.4 Page
custom [creator_function] [leave_function] [caption]
  OR
(license|components|directory|instfiles|uninstConfirm) [pre_function] [show_function] [leave_function]
Adds an installer page. See the above sections for more information about built-in versus custom pages and about callback functions.


4.5.5 UninstPage
custom [creator_function] [leave_function] [caption]
  OR
(license|components|directory|instfiles|uninstConfirm) [pre_function] [show_function] [leave_function]
Adds an uninstaller page. See the above sections for more information about built-in versus custom pages and about callback functions.


4.5.6 PageEx
[un.](custom|uninstConfirm|license|components|directory|instfiles)
Adds an installer page or an uninstaller page if the un. prefix was used. Every PageEx must have a matching
PageExEnd . In a PageEx block you can set options that are specific to this page and will not be used for other pages. Options that are not set will revert to what was set outside the PageEx block or the default if nothing was set. To set the sub-caption for a page use Caption or SubCaption to set the default. To set the callback functions for a page set with PageEx use PageCallbacks . See the above sections for more information about built-in versus custom pages.
Example usage:
PageEx license
   LicenseText "Readme"
   LicenseData readme.rtf
 PageExEnd
 PageEx license
   LicenseData license.txt
   LicenseForceSelection checkbox
 PageExEnd



4.5.7 PageExEnd
Ends a PageEx block.


4.5.8 PageCallbacks
([creator_function] [leave_function]) | ([pre_function] [show_function] [leave_function])
Sets the callback functions for a page defined using
PageEx . Can only be used inside a PageEx block. See the above sections for more information about callback functions.


4.6 Sections
Each NSIS installer contains one or more Sections. Each These sections are created, modified, and ended with the following commands.


4.6.1 Section Commands



4.6.1.1 AddSize
size_kb
Tells the installer that the current section needs an additional "size_kb" kilobytes of disk space. Only valid within a section (will have no effect outside of a section or in a function).


4.6.1.2 Section
[/o] [([!]|[-])section_name] [section index output]
Begins and opens a new section. If section_name is empty, omitted, or begins with a -, then it is a hidden section and the user will not have the option of disabling it. If the section name is 'Uninstall', then it is a special Uninstall Section. If section index output is specified, the parameter will be !defined with the section index (that can be used for
SectionSetText etc). If the section name begins with a !, the section will be displayed as bold. If the Switch /o is specified than the Section is unselected by default.


4.6.1.3 SectionEnd
This command closes the current open section.


4.6.1.4 SectionIn
insttype_index [insttype_index] [RO]
This command specifies which install types (see
InstType ) the current section defaults to the enabled state in. Multiple SectionIn commands can be specified (they are combined). If you specify RO as a parameter, then the section will be read-only, meaning the user won't be able to change its state.


4.6.1.5 SubSection
[/e] Caption [section index output]
This command inserts a subsection. The subsection must be closed with SubSectionEnd, and should contain 1 or more Sections. If the subsection name begins with a !, the subsection will be displayed as bold. If /e is present, the sub sections of the sub section will be expanded by default. If section index output is specified, the parameter will be !defined with the section index (that can be used for SectionSetText etc).


4.6.1.6 SubSectionEnd
Closes a subsection opened with SubSection.


4.6.2 Uninstall Section
A special Section named 'Uninstall' must be created in order to generate an uninstaller. This section should remove all files, registry keys etc etc that were installed by the installer, from the system. Here is an example of a simple uninstall section:
Section "Uninstall"
  Delete $INSTDIR\Uninst.exe ; delete self (see explanation below why this works)
  Delete $INSTDIR\myApp.exe
  RMDir $INSTDIR
  DeleteRegKey HKLM SOFTWARE\myApp
SectionEnd
The first
Delete instruction works (deleting the uninstaller), because the uninstaller is transparently copied to the system temporary directory for the uninstall.


4.7 Functions
Functions are similar to Sections in that they contain zero or more instructions. User functions are not called by the installer directly, instead they are called from Sections using the Call instruction. Callback functions will be called by the installer when a certain event occurs.
Functions must be declared outside of Sections or other Functions.


4.7.1 Function Commands



4.7.1.1 Function
[function_name]
Begins and opens a new function. Function names beginning with "." (e.g. ".Whatever") are generally reserved for callback functions. Function names beginning with "un." are functions that will be generated in the Uninstaller. Hence, normal install Sections and functions cannot call uninstall functions, and the Uninstall Section and uninstall functions cannot call normal functions.


4.7.1.2 FunctionEnd
This command closes the current open function.


4.7.2 Callback Functions
You can create callback functions which have special names, that will be called by the installer at certain points in the install. Below is a list of currently available callbacks:


4.7.2.1 Install Callbacks



4.7.2.1.1 .onGUIInit
This callback will be called just before the first page is loaded and the installer dialog is shown, allowing you to tweak the user interface.
Example:
!include "${NSISDIR}\Include\WinMessages.nsh"
 Function .onGUIInit
   # 1028 is the id of the branding text control
   GetDlgItem $R0 $HWNDPARENT 1028
   CreateFont $R1 "Tahoma" 10 700
   SendMessage $R0 ${WM_SETFONT} $R1 0
   # set background color to white and text color to red
   SetCtlColors $R0 FFFFFF FF0000
 FunctionEnd



4.7.2.1.2 .onInit
This callback will be called when the installer is nearly finished initializing. If the '.onInit' function calls
Abort , the installer will quit instantly.
Here are two examples of how this might be used:
Function .onInit
   MessageBox MB_YESNO "This will install. Continue?" IDYES NoAbort
     Abort ; causes installer to quit.
   NoAbort:
 FunctionEnd
or:
Function .onInit
   ReadINIStr $INSTDIR $WINDIR\wincmd.ini Configuration InstallDir
   StrCmp $INSTDIR "" 0 NoAbort
     MessageBox MB_OK "Windows Commander not found. Unable to get install path."
     Abort ; causes installer to quit.
   NoAbort:
 FunctionEnd



4.7.2.1.3 .onInstFailed
This callback is called when the user hits the 'cancel' button after the install has failed (if it could not extract a file, or the install script used the
Abort command).
Example:
Function .onInstFailed
    MessageBox MB_OK "Better luck next time."
  FunctionEnd



4.7.2.1.4 .onInstSuccess
This callback is called when the install was successful, right before the install window closes (which may be after the user clicks 'Close' if
AutoCloseWindow or SetAutoClose is set to false).
Example:
Function .onInstSuccess
    MessageBox MB_YESNO "Congrats, it worked. View readme?" IDNO NoReadme
      Exec notepad.exe ; view readme or whatever, if you want.
    NoReadme:
  FunctionEnd



4.7.2.1.5 .onGUIEnd
This callback is called right after the installer window closes. Use it to free any user interface related plug-ins if needed.


4.7.2.1.6 .onMouseOverSection
This callback is called whenever the mouse position over the sections tree has changed. This allows you to set a description for each section for example. The section id on which the mouse is over currently is stored, temporarily, in $0.
Example:
Function .onMouseOverSection
    FindWindow $R0 "#32770" "" $HWNDPARENT
    GetDlgItem $R0 $R0 1043 ; description item
    StrCmp $0 0 "" +2
      SendMessage $R0 ${WM_SETTEXT} 0 "first section description"
    StrCmp $0 1 "" +2
      SendMessage $R0 ${WM_SETTEXT} 0 "second section description"
  FunctionEnd



4.7.2.1.7 .onSelChange
Called when the selection changes on the
Pages . Useful for using with SectionSetFlags and SectionGetFlags .


4.7.2.1.8 .onUserAbort
This callback is called when the user hits the 'cancel' button, and the install hasn't already failed. If this function calls
Abort , the install will not be aborted.
Example:
Function .onUserAbort
   MessageBox MB_YESNO "Abort install?" IDYES NoCancelAbort
     Abort ; causes installer to not quit.
   NoCancelAbort:
 FunctionEnd



4.7.2.1.9 .onVerifyInstDir
This callback enables control over whether or not an installation path is valid for your installer. This code will be called every time the user changes the install directory, so it shouldn't do anything crazy with
MessageBox or the likes. If this function calls Abort , the installation path in $INSTDIR is deemed invalid.
Example:
Function .onVerifyInstDir
    IfFileExists $INSTDIR\Winamp.exe PathGood
      Abort ; if $INSTDIR is not a winamp directory, don't let us install there
    PathGood:
  FunctionEnd



4.7.2.2 Uninstall Callbacks



4.7.2.2.1 un.onGUIInit
This callback will be called just before the first page is loaded and the installer dialog is shown, allowing you to tweak the user interface.
Have a look at
.onGUIInit for an example.


4.7.2.2.2 un.onInit
This callback will be called when the uninstaller is nearly finished initializing. If the 'un.onInit' function calls Abort, the uninstaller will quit instantly. Note that this function can verify and/or modify $INSTDIR if necessary.
Here are two examples of how this might be used:
Function un.onInit
    MessageBox MB_YESNO "This will uninstall. Continue?" IDYES NoAbort
      Abort ; causes uninstaller to quit.
    NoAbort:
  FunctionEnd
or:
Function un.onInit
    IfFileExists $INSTDIR\myfile.exe found
      Messagebox MB_OK "Uninstall path incorrect"
      Abort
    found:
  FunctionEnd



4.7.2.2.3 un.onUninstFailed
This callback is called when the user hits the 'cancel' button after the uninstall has failed (if it used the
Abort or otherwise failed).
Example:
Function un.onUninstFailed
    MessageBox MB_OK "Better luck next time."
  FunctionEnd



4.7.2.2.4 un.onUninstSuccess
This callback is called when the uninstall was successful, right before the install window closes (which may be after the user clicks 'Close' if
SetAutoClose is set to false)..
Example:
Function un.onUninstSuccess
    MessageBox MB_OK "Congrats, it's gone."
  FunctionEnd



4.7.2.2.5 un.onGUIEnd
This callback is called right after the uninstaller window closes. Use it to free any user interface related plug-ins if needed.


4.7.2.2.6 un.onUserAbort
This callback is called when the user hits the 'cancel' button and the uninstall hasn't already failed. If this function calls Abort, the install will not be aborted.
Example:
Function un.onUserAbort
    MessageBox MB_YESNO "Abort uninstall?" IDYES NoCancelAbort
      Abort ; causes uninstaller to not quit.
    NoCancelAbort:
  FunctionEnd



4.8 Installer Attributes



4.8.1 General Attributes
The commands below all adjust attributes of the installer. These attributes control how the installer looks and functions, including which pages are present in the installer, as what text is displayed in each part of each page, how the installer is named, what icon the installer uses, the default installation directory, what file it writes out, and more. Note that these attributes can be set anywhere in the file except in a Section or Function. With the exception of InstallDir, none of these attributes allow use of Variables other than $\r and $\n in their strings.
<b>Defaults are bold</b>


4.8.1.1 AddBrandingImage
(left|right|top|bottom) (width|height) [padding]
Adds a branding image on the top, bottom, left, or right of the installer. Its size will be set according to the width/height specified, the installer width/height and the installer font. The final size will not always be what you requested; have a look at the output of the command for the actual size. Because this depends on the installer font, you should use SetFont before AddBrandingImage. The default padding value is 2.


4.8.1.2 AllowRootDirInstall
true|<b>false</b>
Controls whether or not installs are enabled to the root directory of a drive, or directly into a network share. Set to 'true' to change the safe behavior, which prevents users from selecting C:\ or \\Server\Share as an install (and later on, uninstall) directory. For additional directory selection page customizability, see
.onVerifyInstDir .


4.8.1.3 AutoCloseWindow
true|<b>false</b>
Sets whether or not the install window automatically closes when completed. This is overrideable from a section using
SetAutoClose .


4.8.1.4 BGGradient
[<b>off</b>|(topc botc [textcolor|notext])]
Specifies whether or not to use a gradient background window. If 'off', the installer will not show a background window, if no parameters are specified, the default black to blue gradient is used, and otherwise the top_color or bottom_color are used to make a gradient. Top_color and bottom_color are specified using the form RRGGBB (in hexadecimal, as in HTML, only minus the leading '#', since # can be used for comments). 'textcolor' can be specified as well, or 'notext' can be specified to turn the big background text off.


4.8.1.5 BrandingText
/TRIM(LEFT|RIGHT|CENTER) text
Sets the text that is shown (by default it is 'Nullsoft Install System vX.XX') in the bottom of the install window. Setting this to an empty string ("") uses the default; to set the string to blank, use " " (a space). If it doesn't matter to you, leave it the default so that everybody can know why the installer didn't suck. heh. Use /TRIMLEFT, /TRIMRIGHT or /TRIMCENTER to trim down the size of the control to the size of the string.


4.8.1.6 Caption
caption
Sets what the titlebars of the installer will display. By default, it is 'Name Setup', where Name is specified with the
Name . You can, however, override it with 'MyApp Installer' or whatever. If you specify an empty string (""), the default will be used (you can however specify " " to achieve a blank string).
If used inside a PageEx block, it sets the caption for the page.


4.8.1.7 ChangeUI
dialog ui_file.exe
Replaces dialog ( IDD_LICENSE , IDD_DIR , IDD_SELCOM , IDD_INST , IDD_INSTFILES , IDD_UNINST or IDD_VERIFY ) by a dialog with the same resource ID in ui_file.exe. You can also specify 'all' as the dialog if you wish to load replace all 7 of the dialogs at once from the same UI file. For some example UIs look at Contrib\UIs under your NSIS directory.


4.8.1.8 CheckBitmap
bitmap.bmp
Specifies the bitmap with the images used for the checks of the component-selection page treeview.
This bitmap should have a size of 96x16 pixels, no more than 8bpp (256 colors) and contain six 16x16 images for the different states (in order: selection mask, not checked, checked, greyed out, unchecked & read-only, checked & read-only). Use magenta as mask color (this area will be transparent).


4.8.1.9 CompletedText
text
Replaces the default text ("Completed") that is printed at the end of the install if parameter is specified. Otherwise, the default is used.


4.8.1.10 ComponentText
[text [subtext] [subtext2]]
Specifies a string that is above the component list. This can be something that notifies the user what it is they are actually installing. Note that if no parameter is specified, or if the ComponentText command is omitted, then the component page will not be visible, and all of the sections will be installed. Note: if text is specified and non-empty and you leave subtext or subtext2 empty, the defaults will be used (to set one to blank, use a string like " "). empty strings mean default on subtext and subtext2. Likewise, if you wish to enable the component page, but don't want any text on the top line, set text to " ".


4.8.1.11 CRCCheck
<b>on</b>|off|force
Specifies whether or not the installer will perform a CRC on itself before allowing an install. Note that if the user uses /NCRC on the command line when executing the installer, and you didn't specify 'force', the CRC will not occur, and the user will be allowed to install a (potentially) corrupted installer.


4.8.1.12 DetailsButtonText
show details text
Replaces the default details button text of "Show details", if parameter is specified (otherwise the default is used).


4.8.1.13 DirShow
<b>show</b>|hide
Specifies whether or not the user will see the directory selection page. Note that if 'hide' is specified, the installer will still check the validity of the installation path (using internal logic and .onVerifyInstDir if it is declared). If the path is deemed invalid, the directory page will be shown. To completely disable the Directory page (and install without prompting, even if a valid installation path is not available), specify DirText with no parameter (this might be useful if the installer installs everything into $SYSDIR or something like that).


4.8.1.14 DirText
[text] [subtext] [browse_button_text] [browse_dlg_text]
Atleast the first parameter is required. Specifies a string that is above the directory selection area. If this command is not specified, or no parameter is specified, then the directory page is never visible to the user (even if DirShow show is specified). Subtext overrides the default text above the path entry box ("Select the directory to install MyApp in:"). Browse_button_text overrides the default browse button text ("Browse...").


4.8.1.15 DirVar
user_var(dir input/output)
Specifies which variable is to be used to contain the directory selected. This variable should contain the default value too. This allows to easily create two different directory pages that will not require you to move values in and out of $INSTDIR. The default variable is $INSTDIR. This can only be used in
PageEx and for directory and uninstConfirm pages.


4.8.1.16 FileErrorText
file error text
Replaces the default text that comes up when a file cannot be written to. This string can contain a reference to $0, which is the filename ($0 is temporarily changed to this value). Example: "Can not write to file $\r$\n$0$\r$\ngood luck, bitch.".


4.8.1.17 Icon
[path\]icon.ico
Sets the icon of the installer. Every icon in the icon file will be included in the installer. Note that if you use different icons for installer and uninstaller the file size and structure of the icons has to match otherwise the build of your installer will fail.


4.8.1.18 InstallButtonText
install button text
If parameter is specified, overrides the default install button text (of "Install") with the specified text.


4.8.1.19 InstallColors
/windows | (foreground_color background_color)
Sets the colors to use for the install info screen (the default is 00FF00 000000. Use the form RRGGBB (in hexadecimal, as in HTML, only minus the leading '#', since # can be used for comments). Note that if "/windows" is specified as the only parameter, the default windows colors will be used.


4.8.1.20 InstallDir
definstdir
Sets the default installation directory is. See the variables section for variables that can be used to make this string (especially $PROGRAMFILES). Note that the part of this string following the last \ will be used if the user selects 'browse', and may be appended back on to the string at install time (to disable this, end the directory with a \ (which will require the entire parameter to be enclosed with quotes)). If this doesn't make any sense, play around with the browse button a bit.


4.8.1.21 InstallDirRegKey
root_key subkey key_name
This attribute tells the installer to check a string in the registry, and use it for the install dir if that string is valid. If this attribute is present, it will override the InstallDir attribute if the registry key is valid, otherwise it will fall back to the InstallDir default. When querying the registry, this command will automatically remove any quotes. If the string ends in ".exe", it will automatically remove the filename component of the string (i.e. if the string is "C:\program files\poop\poop.exe", it will know to use "C:\program files\poop"). For more advanced install directory configuration, set $INSTDIR in .onInit.


4.8.1.22 InstProgressFlags
[flag [...]]
Valid values for flag are "smooth" (smooth the progress bar) or "colored" (color the progress bar with the colors set by InstallColors. Examples: "InstProgressFlags" (default old-school windows look), "InstProgressFlags smooth" (new smooth look), "InstProgressFlags smooth colored" (colored smooth look whee). Note: neither "smooth" or "colored" work with
XPStyle on when the installer runs on Windows XP with a modern theme.


4.8.1.23 InstType
install_type_name | /NOCUSTOM | /CUSTOMSTRING=str | /COMPONENTSONLYONCUSTOM
Adds an install type to the install type list, or disables the custom install type. There can be as many as 32 types, each one specifying the name of the install. Instead of an "hard-coded" name you can use User Variables which are processed at Runtime. This allows you to change InstType name dynamically. Another way of changing the InstType name during runtime is the
InstTypeSetText command. The difference is that with InstTypeSetText you are saving your precious user variables. The first type is the default (generally 'Typical'). Each type is numbered, starting at 1. See SectionIn for information on how those numbers are used. If the /NOCUSTOM switch is specified, then the "custom" install type is disabled, and the user has to choose one of the pre-defined install types. Alternatively, if the /CUSTOMSTRING switch is specified, the parameter will override the "Custom" install type text. Alternatively, if the /COMPONENTSONLYONCUSTOM flag is specified, the component list will only be show
n if the "Custom" install type is selected.


4.8.1.24 LicenseBkColor
color | <b>/gray</b> | /windows
Sets the background color of the license data. Color is specified using the form RRGGBB (in hexadecimal, as in HTML, only minus the leading '#', since # can be used for comments). Default is '/gray'. You can also use the Windows OS defined color by using '/windows'.


4.8.1.25 LicenseData
licdata.(txt|rtf)
Specifies a text file or a RTF file to use for the license that the user can read. Omit this to not have a license displayed. Note that the file must be in the evil DOS text format (\r\n, yeah!). To define a multilingual license data use
LicenseLangString .
If you make your license file a RTF file it is recommended you edit it with WordPad and not MS Word. Using WordPad will result in a much smaller file.


4.8.1.26 LicenseForceSelection
(checkbox [accept_text] | radiobuttons [accept_text] [decline_text] | <b>off</b>)
Specifies if the displayed license must be accept explicit or not. This can be done either by a checkbox or by radiobuttons. By default the "next button" is disabled and will only be enabled if the checkbox is enabled or the right radio button is selected. If off is specified the "next button" is enabled by default.


4.8.1.27 LicenseText
[text [button_text]]
Specifies a string that is above the license text. Omit this to not have a license displayed. If button_text is specified, it will override the default button text of "I Agree".


4.8.1.28 MiscButtonText
[back button text [next button text] [cancel button text] [close button text]]
Replaces the default text strings for the four buttons (< Back, Next >, Cancel and Close). If parameters are omitted, the defaults are used.


4.8.1.29 Name
name
Sets the name of the installer. The name is usually simply the product name such as 'MyApp' or 'CrapSoft MyApp'.


4.8.1.30 OutFile
[path\]install.exe
Specifies the output file that the MakeNSIS should write the installer to. This is just the file that MakeNSIS writes, it doesn't affect the contents of the installer.


4.8.1.31 SetFont
font_face_name font_size
Sets the installer font. Please remember that the font you choose must be present on the user's machine as well. Don't use rare fonts that only you have.


4.8.1.32 ShowInstDetails
<b>hide</b>|show|nevershow
Sets whether or not the details of the install are shown. Can be 'hide' to hide the details by default, allowing the user to view them, or 'show' to show them by default, or 'nevershow', to prevent the user from ever seeing them. Note that sections can override this using SetDetailsView.


4.8.1.33 ShowUninstDetails
<b>hide</b>|show|nevershow
Sets whether or not the details of the uninstall are shown. Can be 'hide' to hide the details by default, allowing the user to view them, or 'show' to show them by default, or 'nevershow', to prevent the user from ever seeing them. Note that sections can override this using SetDetailsView.


4.8.1.34 SilentInstall
<b>normal</b>|silent|silentlog
Specifies whether or not the installer should be silent. If it is 'silent' or 'silentlog', all sections that have the SF_SELECTED flag are installed quietly (you can set this flag using see
SectionSetFlags ), with no screen output from the installer itself (MessageBoxes are still displayed on error, and the script can still display whatever it wants). Note that if this is set to 'normal' and the user runs the installer with /S (case sensitive) on the command line, it will behave as if SilentInstall 'silent' was used. Note: see also LogSet .


4.8.1.35 SilentUnInstall
<b>normal</b>|silent
Specifies whether or not the uninstaller should be silent. If it is 'silent' or 'silentlog', the uninstall section will run quietly, with no screen output from the uninstaller itself (MessageBoxes are still displayed on error, and the script can still display whatever it wants). Note that if this is set to 'normal' and the user runs the uninstaller with /S on the command line, it will behave as if SilentUnInstall 'silent' was used. Note: see also
LogSet .


4.8.1.36 SpaceTexts
[req text [avail text]]
If parameters are specified, overrides the space required and space available text ("Space required: " and "Space available: " by default). If 'none' is specified as the required text no space texts will be shown.


4.8.1.37 SubCaption
[page_number subcaption]
Overrides the subcaptions for each of the installer pages (0=": License Agreement",1=": Installation Options",2=": Installation Directory", 3=": Installing Files", 4=": Completed"). If you specify an empty string (""), the default will be used (you can however specify " " to achieve a blank string)


4.8.1.38 UninstallButtonText
text
Changes the text of the button that by default says "Uninstall" in the uninstaller. If no parameter is specified, the default text is used. See also
WriteUninstaller (replaces UninstallEXEName).


4.8.1.39 UninstallCaption
caption
Sets what the titlebars of the uninstaller will display. By default, it is 'Name Uninstall', where Name is specified with the Name command. You can, however, override it with 'MyApp uninstaller' or whatever. If you specify an empty string (""), the default will be used (you can however specify " " to achieve a blank string)


4.8.1.40 UninstallIcon
[path\]icon.ico
Sets the icon of the uninstaller. This icon file must have the exact same structure as the installer icon file.


4.8.1.41 UninstallSubCaption
page_number subcaption
Overrides the subcaptions for each of the uninstaller pages (0=": Confirmation",1=": Uninstalling Files",2=": Completed"). If you specify an empty string (""), the default will be used (you can however specify " " to achieve a blank string)


4.8.1.42 UninstallText
text [subtext]
Specifies the text on the first page of the uninstaller. If subtext is specified and not empty, it will replace the default secondary text on that page, "Uninstall from:".


4.8.1.43 WindowIcon
<b>on</b>|off
Sets whether or not the installer's icon is being displayed.


4.8.1.44 XPStyle
on|<b>off</b>
Sets whether or not an XP manifest will be added to the installer. This affects the uninstaller too.


4.8.2 Compiler Flags
The following commands change how the compiler generates code and compresses data. These commands are valid anywhere in the script, and effect every line below where each one is placed (until overridden by another command).


4.8.2.1 AllowSkipFiles
<b>on</b>|off
This command specifies whether the user should be able to skip a file or not. A user has an option to skip a file if
SetOverwrite is set to on (default) and the installer fails to open a file for writing when trying to extract a file. If off is used the ignore button which allows the user to skip the file will not show and the user will only have an option to abort the installation (Cancel button) or retry opening the file for writing (Retry button). If on is used the user will have an option to skip the file (error flag will be set - see SetOverwrite ).


4.8.2.2 FileBufSize
buffer_size_in_mb
This command sets the size of the compiler's internal file buffers. This command allows you to control the compiler's memory usage by limiting how much of a given file it will load into memory at once. Since the compiler needs both input and output, twice the memory size specified could be used at any given time for file buffers. This command does not limit the compression buffers which could take another couple of MB, neither does it limit the compiler's other internal buffers, but those shouldn't normally top 1MB anyway. Specifying a very small number could decrease performance. Specifying a very large number could exhaust system resources and force the compiler to cancel the compilation process. The default value is 32MB.


4.8.2.3 SetCompress
<b>auto</b>|force|off
This command sets the compress flag which is used by the installer to determine whether or not data should be compressed. Typically the SetCompress flag will effect the commands after it, and the last SetCompress command in the file also determines whether or not the install info section and uninstall data of the installer is compressed. If compressflag is 'auto', then files are compressed if the compressed size is smaller than the uncompressed size. If compressflag is set to 'force', then the compressed version is always used. If compressflag is 'off' then compression is not used (which can be faster). Note that this option has no effect on bzip2 installers (compression is always used on bzip2 installers).


4.8.2.4 SetCompressor
<b>zlib</b>|bzip2
This command sets the compression algorithm used to compress files/data in the installer. Options are ZLib or BZip2. ZLib (the default) uses deflate compression. This mode uses less memory at runtime and is faster. BZip2 compression is usually better for large installers, but it is slower and uses a lot more memory at runtime.


4.8.2.5 SetDatablockOptimize
<b>on</b>|off
This command tells the compiler whether or not to do datablock optimizations. Datablock optimizations have the compiler check to see if any data being added to the data block is already in the data block, and if so, it is simply referenced as opposed to added (can save a little bit of size). It is highly recommended to leave this option on.


4.8.2.6 SetDateSave
<b>on</b>|off
This command sets the file date/time saving flag which is used by the File command to determine whether or not to save the last write date and time of the file, so that it can be restored on installation. Valid flags are 'on' and 'off'. 'on' is the default.


4.8.2.7 SetOverwrite
<b>on</b>|off|try|ifnewer|ifdiff|lastused
This command sets the overwrite flag which is used by the File command to determine whether or not the file should overwrite any existing files that are present. If overwriteflag is 'on', files are overwritten (this is the default). If overwriteflag is 'off', files that are already present are not overwritten. If overwriteflag is 'try', files are overwritten if possible (meaning that if the file is not able to be written to, it is skipped without any user interaction). If overwriteflag is 'ifnewer', then files are only overwritten if the existing file is older than the new file. If overwriteflag is 'ifdiff', then files are only overwritten if the existing file is older or newer than the new file. Note that when in 'ifnewer' or 'ifdiff' mode, the destination file's date is set, regardless of what SetDateSave is set to.


4.8.2.8 SetPluginUnload
<b>manual</b>|alwaysoff
This command sets the unload plugin flag which is by CallInstDLL and plugin calls (dll::func). Setting this to always off will behave as if you have added the /NOUNLOAD to every CallInstDLL and plugin call. Setting this to manual will only not unload if you specifically use /NOUNLOAD.


4.8.3 Version Information



4.8.3.1 VIAddVersionKey
[/LANG=lang_id] keyname value
Adds a field in the Version Tab of the File Properties. This can either be a field provided by the system or a user defined field.
The following fields are provided by the System:The name of these fields are translated on the target system, whereas user defined fields remain untranslated.


4.8.3.2 VIProductVersion
[version_string_X.X.X.X]
Adds the Product Version on top of the Version Tab in the Properties of the file.


4.9 Instructions



4.9.1 Basic Instructions
The instructions that NSIS uses for scripting are sort of a cross between PHP and assembly. There are no real high level language constructs, but the instructions themselves are (for the most part) high level, and you have handy string capability (i.e. you don't have to worry about concatenating strings, etc). You essentially have 25 registers (20 general purpose, 5 special purpose), and a stack.


4.9.1.1 Delete
[/REBOOTOK] file
Delete file (which can be a file or wildcard, but should be specified with a full path) from the target system. If /REBOOTOK is specified and the file cannot be deleted then the file is deleted when the system reboots -- if the file will be deleted on a reboot, the reboot flag will be set. The error flag is set if files are found and cannot be deleted. The error flag is not set from trying to delete a file that does not exist.


4.9.1.2 Exec
command
Execute the specified program and continue immediately. Note that the file specified must exist on the target system, not the compiling system. $OUTDIR is used for the working directory. The error flag is set if the process could not be launched. Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: Exec '"$INSTDIR\command.exe" parameters'. If you don't put it in quotes it will not work on Windows 9x with or without parameters.


4.9.1.3 ExecShell
action command [parameters] [SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED]
Execute the specified program using ShellExecute. Note that action is usually "open", "print", etc, but can be an empty string to use the default action. Parameters and the show type are optional. $OUTDIR is used for the working directory. The error flag is set if the process could not be launched.


4.9.1.4 ExecWait
command [user_var(exit code)]
Execute the specified program and wait for the executed process to quit. See Exec for more information. If no output variable is specified ExecWait sets the error flag if the program executed returns a nonzero error code, or if there is an error. If an output variable is specified, ExecWait sets the variable with the exit code (and only sets the error flag if an error occurs; if an error occurs the contents of the user variable are undefined). Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: ExecWait '"$INSTDIR\command.exe" parameters'. If you don't put it in quotes it will not work on Windows 9x with or without parameters.


4.9.1.5 File
[/nonfatal] [/a] ([/r] (file|wildcard) [...] | /oname=file.dat infile.dat)
Adds file(s) to be extracted to the current output path ($OUTDIR).


4.9.1.6 Rename
[/REBOOTOK] source_file dest_file
Rename source_file to dest_file. Functions just like the Win32 API MoveFile, which means you can move a file from anywhere on the system to anywhere else, and you can move a directory to somewhere else on the same drive. It also means the destination file must not exist or the move will fail for regular Rename operation (no /REBOOTOK). If /REBOOTOK is specified, and the file cannot be moved (if, for example, the destination exists), then the file is moved when the system reboots -- if the file will be moved on a reboot, the reboot flag will be set. The error flag is set if the file cannot be renamed (and /REBOOTOK is not used) or if the source file does not exist.


4.9.1.7 ReserveFile
[/nonfatal] [/r] file [file...]
Reserves a file in the data block for later use. As files are added in the order they are used in the script files that are used in the .onInit function, for example, might be added last and slow the loading of the installer. This is where this command comes useful, allowing you to speed up the loading process by including the file at the top of the data block instead of letting NSIS seek all the way down to the bottom of the compressed data block.
See
File for more information about the parameters.


4.9.1.8 RMDir
[/r|/REBOOTOK] directory_name
Remove the specified directory (which should be a full path). Without /r, the directory will only be removed if it is completely empty. If /r is specified, the directory will be removed recursively, so all directories and files in the specified directory will be removed. If /REBOOTOK is specified, and the directory cannot be overwritten, then the directory will be deleted when the system reboots -- if the directory will be removed on a reboot, the reboot flag will be set. The error flag is set if the directory cannot be removed.


4.9.1.9 SetOutPath
outpath
Sets the output path ($OUTDIR) and creates it (recursively if necessary), if it does not exist. Must be a full pathname, usually is just $INSTDIR (you can specify $INSTDIR if you are lazy with a single "-").


4.9.2 Registry, INI, File Instructions
In all of the below registry instructions use an empty string (just two quotes with nothing between them - "") as the key name to specify the default key which is shown as (Default) in regedit.exe.


4.9.2.1 DeleteINISec
ini_filename section_name
Deletes the entire section [section_name] from ini_filename. If the section could not be removed from the ini file, the error flag is set. It does not set the error flag if the section could not be found.


4.9.2.2 DeleteINIStr
ini_filename section_name str_name
Deletes the string str_name from section [section_name] from ini_filename. If the string could not be removed from the ini file, the error flag is set. It does not set the error flag if the string could not be found.


4.9.2.3 DeleteRegKey
[/ifempty] root_key subkey
Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys (otherwise, the whole registry tree will be removed). Valid values for root_key are listed under WriteRegStr. The error flag is set if the key could not be removed from the registry (or if it didn't exist to begin with).


4.9.2.4 DeleteRegValue
root_key subkey key_name
Deletes a registry value. Valid values for root_key are listed under WriteRegStr. The error flag is set if the value could not be removed from the registry (or if it didn't exist to begin with).


4.9.2.5 EnumRegKey
user_var(output) root_key subkey index
Set user variable $x with the name of the 'index'th registry key in root_key\Subkey. Valid values for root_key are listed under WriteRegStr. Returns an empty string if there are no more keys, and returns an empty string and sets the error flag if there is an error.


4.9.2.6 EnumRegValue
user_var(output) root_key subkey index
Set user variable $x with the name of the 'index'th registry value in root_key\Subkey. Valid values for root_key are listed under WriteRegStr. Returns an empty string if there are no more values, and returns an empty string and sets the error flag if there is an error.


4.9.2.7 ExpandEnvStrings
user_var(output) string
Expands environment variables in "string" into the user variable $x. If error, the variable is set to empty, and the error flag is set.


4.9.2.8 FlushINI
ini_filename
Flushes the INI file's buffers. Windows 9x keeps all changes to the INI file in memory. This command causes the changes to be written to the disk immediately. Use it if you edit the INI manually, delete it, move it or copy it right after you change it with
WriteINIStr , DeleteINISec or DeleteINIStr .


4.9.2.9 ReadEnvStr
user_var(output) name
Reads from the environment string "name" and sets the value into the user variable $x. If there is an error reading the string, the user variable is set to empty, and the error flag is set.


4.9.2.10 ReadINIStr
user_var(output) ini_filename section_name entry_name
Reads from entry_name in [section_name] of ini_filename and stores the value into user variable $x. The error flag will be set and $x will be assigned to an empty string if the entry is not found.


4.9.2.11 ReadRegDWORD
user_var(output) root_key sub_key name
Reads a 32 bit DWORD from the registry into the user variable $x. Valid values for root_key are listed under WriteRegStr. The error flag will be set and $x will be set to an empty string ("" which is 0) if the DWORD is not present. If the value is present, but is not a DWORD, it will be read as a string and the error flag will be set.


4.9.2.12 ReadRegStr
user_var(output) root_key sub_key name
Reads from the registry into the user variable $x. Valid values for root_key are listed under WriteRegStr. The error flag will be set and $x will be set to an empty string ("") if the string is not present. If the value is present, but is of type REG_DWORD, it will be read and converted to a string and the error flag will be set.


4.9.2.13 WriteINIStr
ini_filename section_name entry_name value
Writes entry_name=value into [section_name] of ini_filename. The error flag is set if the string could not be written to the ini file.


4.9.2.14 WriteRegBin
root_key subkey key_name valuedata
This command writes a block of binary data to the registry. Valid values for root_key are listed under WriteRegStr. Valuedata is in hexadecimal (e.g. DEADBEEF01223211151). The error flag is set if the binary data could not be written to the registry. If the registry key doesn't exist it will be created.


4.9.2.15 WriteRegDWORD
root_key subkey key_name value
This command writes a dword (32 bit integer) to the registry (a user variable can be specified). Valid values for root_key are listed under WriteRegStr. The error flag is set if the dword could not be written to the registry. If the registry key doesn't exist it will be created.


4.9.2.16 WriteRegStr
root_key subkey key_name value
WriteRegExpandStr root_key subkey key_name value Write a string to the registry. root_key must be one of:The error flag is set if the string could not be written to the registry. The type of the string will be REG_SZ for WriteRegStr, or REG_EXPAND_STR for WriteRegExpandStr. If the registry key doesn't exist it will be created.


4.9.3 General Purpose Instructions



4.9.3.1 CallInstDLL
dllfile [/NOUNLOAD] function_name
Calls a function_name inside a NSIS extension DLL. See Contrib\ExDLL for an example of how to make one. Extension DLLs can access the stack and variables. Use /NOUNLOAD to force the installer to leave the DLL loaded.


4.9.3.2 CopyFiles
[/SILENT] [/FILESONLY] filespec_on_destsys destination_path [size_of_files_in_kb]
Copies files from the source to the destination on the installing system. Useful with $EXEDIR if you want to copy from installation media, or to copy from one place to another on the system. Uses SHFileOperation, so the user might see a status window of the copy operation if it is large (to disable this, use /SILENT). The last parameter specifies how big the copy is (in kilobytes), so that the installer can approximate the disk space requirements. On error, or if the user cancels the copy (only possible when /SILENT was omitted), the error flag is set. If /FILESONLY is specified, only files are copied.


4.9.3.3 CreateDirectory
path_to_create
Creates (recursively if necessary) the specified directory. The error flag is set if the directory couldn't be created.


4.9.3.4 CreateShortCut
link.lnk target.file [parameters [icon.file [icon_index_number [start_options [keyboard_shortcut [description]]]]]]
Creates a shortcut 'link.lnk' that links to 'target.file', with optional parameters 'parameters'.
The icon used for the shortcut is 'icon.file,icon_index_number'; for default icon settings use empty strings for both icon.file and icon_index_number.
start_options should be one of: SW_SHOWNORMAL , SW_SHOWMAXIMIZED , SW_SHOWMINIMIZED , or an empty string.
keyboard_shortcut should be in the form of 'flag|c' where flag can be a combination (using |) of: ALT , CONTROL , EXT , or SHIFT . c is the character to use (a-z, A-Z, 0-9, F1-F24, etc). Note that no spaces are allowed in this string. A good example is "ALT|CONTROL|F8". $OUTDIR is used for the working directory. You can change it by using
SetOutPath before creating the Shortcut.
description should be the description of the shortcut, or comment as it is called under XP.
The error flag is set if the shortcut cannot be created (i.e. the path does not exist, or some other error).


4.9.3.5 GetDLLVersion
filename user_var(high dword output) user_var(low dword output)
Gets the version information from the DLL (or any other executable containing version information) in "filename". Sets the user output variables with the high and low dwords of version information on success; on failure the outputs are empty and the error flag is set. The following example reads the DLL version and copies a human readable version of it into $0:
GetDllVersion "$INSTDIR\MyDLL.dll" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $0 "$R2.$R3.$R4.$R5"



4.9.3.6 GetDLLVersionLocal
localfilename user_var(high dword output) user_var(low dword output)
This is similar to GetDLLVersion, only it acts on the system building the installer (it actually compiles into two StrCpy commands). Sets the two output variables with the DLL version information of the DLL on the build system.


4.9.3.7 GetFileTime
filename user_var(high dword output) user_var(low dword output)
Gets the last write time of "filename". Sets the user output variables with the high and low dwords of the timestamp on success; on failure the outputs are empty and the error flag is set.


4.9.3.8 GetFileTimeLocal
localfilename user_var(high dword output) user_var(low dword output)
This is similar to GetFileTime, only it acts on the system building the installer (it actually compiles into two StrCpy commands). Sets the two output variables with the file timestamp of the file on the build system.


4.9.3.9 GetFullPathName
[/SHORT] user_var(output) path_or_file
Assign to the user variable $x, the full path of the file specified. If the path portion of the parameter is not found, the error flag will be set and $x will be empty. If /SHORT is specified, the path is converted to the short filename form.


4.9.3.10 GetTempFileName
user_var(output) base_dir
Assign to the user variable $x, the name of a temporary file. The file will have been created, so you can then overwrite it with what you please. The name of the temporary file is guaranteed to be unique. If to want the temporary file to be created in another directory than the Windows temp directory, specify a base_dir. Delete the file when done with it.


4.9.3.11 SearchPath
user_var(output) filename
Assign to the user variable $x, the full path of the file named by the second parameter. The error flag will be set and $x will be empty if the file cannot be found. Uses SearchPath() to search the system paths for the file.


4.9.3.12 SetFileAttributes
filename attribute1|attribute2|...
Sets the file attributes of 'filename'. Valid attributes can be combined with | and are:The error flag will be set if the file's attributes cannot be set (i.e. the file doesn't exist, or you don't have the right permissions). You can only set attributes. It's not possible to unset them. If you want to remove an attribute use NORMAL. This way all attributes are erased. This command doesn't support wildcards.


4.9.3.13 RegDLL
dllfile [entrypoint_name]
Loads the specified DLL and calls DllRegisterServer (or entrypoint_name if specified). The error flag is set if an error occurs (i.e. it can't load the DLL, initialize OLE, find the entry point, or the function returned anything other than ERROR_SUCCESS (=0)).


4.9.3.14 UnRegDLL
dllfile
Loads the specified DLL and calls DllUnregisterServer. The error flag is set if an error occurs (i.e. it can't load the DLL, initialize OLE, find the entry point, or the function returned anything other than ERROR_SUCCESS (=0)).


4.9.4 Flow Control Instructions



4.9.4.1 Abort
user_message
Cancels the install, stops execution of script, and displays user_message in the status display. Note: you can use this from
Callback Functions to do special things. Pages also uses Abort for special purposes.


4.9.4.2 Call
function_name | :label_name
Calls the function named function_name. If in the Uninstall section, Call can only be used with function names beginning with "un.". If the parameter starts with a ':' it will be treated as a label (so you can call to a label in your function - this is probably not going to be used most of the time).


4.9.4.3 ClearErrors
Clears the error flag.


4.9.4.4 GetCurrentAddress
user_var(output)
Gets the address of the current instruction (the GetCurrentAddress) and stores it in the output user variable. This user variable then can be passed to Call or Goto.


4.9.4.5 GetFunctionAddress
user_var(output) function_name
Gets the address of the function and stores it in the output user variable. This user variable then can be passed to Call or Goto. Note that if you Goto an address which is the output of GetFunctionAddress, your function will never be returned to (when the function you Goto'd to returns, you return instantly).


4.9.4.6 GetLabelAddress
user_var(output) label
Gets the address of the label and stores it in the output user variable. This user variable then can be passed to Call or Goto. Note that you may only call this with labels accessible from your function, but you can call it from anywhere (which is potentially dangerous). Note that if you Call the output of GetLabelAddress, code will be executed until it Return's (explicitly or implicitly at the end of a function), and then you will be returned to the statement after the Call.


4.9.4.7 Goto
label_to_jump_to | +offset| -offset| user_var(target)
If label is specified, goto the label 'label_to_jump_to:'.
If +offset or -offset is specified, jump is relative by offset instructions. Goto +1 goes to the next instruction, Goto -1 goes to the previous instruction, etc.
If a user variable is specified, jumps to absolute address (generally you will want to get this value from a function like GetLabelAddress). Compiler flag commands and SectionIn aren't instructions so jumping over them has no effect.


4.9.4.8 IfAbort
label_to_goto_if_abort [label_to_goto_if_no_abort]
If abort is called it will "return" true. This can happen if the user choose abort on a file that failed to create (or overwrite) or if the user aborted by hand. This function can only be called from the leave function of the instfiles
Page .


4.9.4.9 IfErrors
jumpto_iferror [jumpto_ifnoerror]
Checks and clears the error flag, and if it is set, it will goto jumpto_iferror, otherwise it will goto jumpto_ifnoerror. The error flag is set by other instructions when a recoverable error (such as trying to delete a file that is in use) occurs.


4.9.4.10 IfFileExists
file_to_check_for jump_if_present [jump_otherwise]
Checks for existence of file(s) file_to_check_for (which can be a wildcard, or a directory), and Gotos jump_if_present if the file exists, otherwise Gotos jump_otherwise. If you want to check to see if a file is a directory, use IfFileExists DIRECTORY\*.*


4.9.4.11 IfRebootFlag
[jump_if_set] [jump_if_not_set]
Atleast one parameter is required. Checks the reboot flag, and jumps to jump_if_set if the reboot flag is set, otherwise jumps to jump_if_not_set. The reboot flag can be set by Delete and Rename, or manually with SetRebootFlag.


4.9.4.12 IfSilent
[jump_if_silent] [jump_if_not]
Atleast one parameter is required. Checks the silent flag, and jumps to jump_if_silent if the installer is silent, otherwise jumps to jump_if_not. The silent flag can be set by
SilentInstall , SilentUnInstall , SetSilent and by the user passing /S on the command line.


4.9.4.13 IntCmp
val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]
Compares two integers val1 and val2. If val1 and val2 are equal, Gotos jump_if_equal, otherwise if val1 < val2, Gotos jump_if_val1_less, otherwise if val1 > val2, Gotos jump_if_val1_more.


4.9.4.14 IntCmpU
val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more]
Compares two unsigned integers val1 and val2. If val1 and val2 are equal, Gotos jump_if_equal, otherwise if val1 < val2, Gotos jump_if_val1_less, otherwise if val1 > val2, Gotos jump_if_val1_more. Performs the comparison as unsigned integers.


4.9.4.15 MessageBox
mb_option_list messagebox_text [return_check jumpto] [return_check_2 jumpto_2]
Displays a MessageBox containing the text "messagebox_text". mb_option_list must be one or more of the following, delimited by |s (e.g. MB_YESNO|MB_ICONSTOP).Return_check can be 0 (or empty, or left off), or one of the following:If the return value of the MessageBox is return_check, the installer will Goto jumpto.


4.9.4.16 Return
Returns from a function or section.


4.9.4.17 Quit
Causes the installer to exit as soon as possible. After Quit is called, the installer will exit (no callback functions will get a chance to run).


4.9.4.18 SetErrors
Sets the error flag.


4.9.4.19 StrCmp
str1 str2 jump_if_equal [jump_if_not_equal]
Compares (case insensitively) str1 to str2. If str1 and str2 are equal, Gotos jump_if_equal, otherwise Gotos jump_if_not_equal.


4.9.5 File Instructions



4.9.5.1 FileClose
handle
Closes a file handle opened with FileOpen.


4.9.5.2 FileOpen
user_var(handle output) filename openmode
Opens a file named "filename", and sets the handle output variable with the handle. The openmode should be one of "r" (read) "w" (write, all contents of file are destroyed) or "a" (append, meaning opened for both read and write, contents preserved). In all open modes, the file pointer is placed at the beginning of the file. If the file cannot be opened, the handle output is set to empty, and the error flag is set.


4.9.5.3 FileRead
handle user_var(output) [maxlen]
Reads a string from a file opened with FileOpen. The string is read until either a newline (or carriage return newline pair) occurs, or until a null byte is read, or until maxlen is met (if specified). Strings are limited to 1024 characters. If the end of file is read and no more data is available, the output string will be empty, and the error flag will be set.


4.9.5.4 FileReadByte
handle user_var(output)
Reads a byte from a file opened with FileOpen. The byte is stored in the output as an integer (0-255). If the end of file is read and no more data is available, the output will be empty, and the error flag will be set.


4.9.5.5 FileSeek
handle offset [mode] [user_var(new position)]
Seeks a file opened with FileOpen. If mode is omitted or specified as SET, the file is positioned to "offset". If mode is specified as CUR, then the file pointer is moved by offset. If mode is specified as END, the file pointer is set to a position relative to EOF. If the final parameter "new position" is specified, the new file position will be stored to that variable.


4.9.5.6 FileWrite
handle string
Writes a string to a file opened with FileOpen. If an error occurs writing, the error flag will be set.


4.9.5.7 FileWriteByte
handle string
Writes the integer interpretation of 'string' to a file opened with FileOpen. Of course you can enter the integer value directly. The following code writes a "Carriage Return / Line Feed" - Enter to the file.
FileWriteByte file_handle "13"
FileWriteByte file_handle "10"
You can If an error occurs writing, the error flag will be set. Note that the low byte of the integer is used, i.e. writing 256 is the same as writing 0, etc.


4.9.5.8 FindClose
handle
Closes a search opened with FindFirst.


4.9.5.9 FindFirst
user_var(handle output) user_var(filename output) filespec
Performs a search for 'filespec', placing the first file found in filename_output (a user variable). It also puts the handle of the search into handle_output (also a user variable). If no files are found, both outputs are set to empty, and the error flag is set. Best used with FindNext and FindClose. Note that the filename output is without path.


4.9.5.10 FindNext
handle user_var(filename_output)
Continues a search began with FindFirst. handle should be the handle_output_variable returned by FindFirst. If the search is completed (there are no more files), filename_output is set to empty, and the error flag is set. Note that the filename output is without path.


4.9.6 Uninstaller Instructions



4.9.6.1 WriteUninstaller
[Path\]exename.exe
Writes the uninstaller to the filename (and optionally path) specified. Only valid from within an install section or function, and requires that you have an uninstall section in your script. See also Uninstall configuration. You can call this one or more times to write out one or more copies of the uninstaller.


4.9.7 Miscellaneous Instructions



4.9.7.1 InitPluginsDir
Initializes the plugins dir (
Constant Variables ) if not already initialized.


4.9.7.2 SetShellVarContext
<b>current</b>|all
Sets the context of $SMPROGRAMS and other shell folders. If set to 'current' (the default), the current user's shell folders are used. If set to 'all', the 'all users' shell folder is used. The all users folder may not be supported on all OSes. If the all users folder is not found, the current user folder will be used. Please take into consideration that a "normal user" has no rights to write in the all users area. Only admins have full access rights to the all users area. You can check this by using the UserInfo Plugin. See Contrib\UserInfo\UserInfo.nsi for an example.


4.9.7.3 Sleep
sleeptime_in_ms
Pauses execution in the installer for sleeptime_in_ms milliseconds. sleeptime_in_ms can be a variable, e.g. "$0" or a number, i.e. "666".


4.9.8 String Manipulation Instructions



4.9.8.1 StrCpy
user_var(destination) str [maxlen] [start_offset]
Sets the user variable $x with str. Note that str can contain other variables, or the user variable being set (concatenating strings this way is possible, etc). If maxlen is specified, the string will be a maximum of maxlen characters (if maxlen is negative, the string will be truncated abs(maxlen) characters from the end). If start_offset is specified, the source is offset by it (if start_offset is negative, it will start abs(start_offset) from the end of the string).


4.9.8.2 StrLen
user_var(length output) str
Sets user variable $x with the length of str.


4.9.9 Stack Support



4.9.9.1 Exch
[user_var | stack_index]
When no parameter is specified, exchanges the top two elements of the stack. When a parameter is specified and is a user variable, exchanges the top element of the stack with the parameter. When a parameter is specified and is a positive integer, Exch will swap the item on the top of the stack with the item that is specified by the offset from the top of the stack in the parameter. If there are not enough items on the stack to accomplish the exchange, a fatal error will occur (to help you debug your code :).


4.9.9.2 Pop
user_var(out)
Pops a string off of the stack into user variable $x. If the stack is empty, the error flag will be set.


4.9.9.3 Push
string
Pushes a string onto the stack. The string can then be Popped off of the stack.


4.9.10 Integer Support



4.9.10.1 IntFmt
user_var(output) format numberstring
Formats the number in "numberstring" using the format "format", and sets the output to user variable $x. Example format strings include "%08X" "%u"


4.9.10.2 IntOp
user_var(output) value1 OP [value2]
Combines value1 and (depending on OP) value2 into the user variable $x. OP is defined as one of the following:


4.9.11 Reboot Instructions



4.9.11.1 Reboot
Reboots the computer. Be careful with this one. If there is an error rebooting, this function sets the error flag and continues. If the reboot is successful, this instruction does not return.


4.9.11.2 SetRebootFlag
true|false
Sets the reboot flag to either true or false.


4.9.12 Install Logging Instructions



4.9.12.1 LogSet
on|<b>off</b>
Sets whether install logging to $INSTDIR\install.log will happen. $INSTDIR must have a value before you call this function or it will not work. Note that NSIS_CONFIG_LOG must be set in the compile configuration file (config.h) on compile time (it is not by default) to support this. See
Compiling NSIS Sources for more information about recompiling NSIS.


4.9.12.2 LogText
text
If installer logging is enabled, inserts text "text" into the log file.


4.9.13 Section Management



4.9.13.1 SectionSetFlags
section_index section_flags
Sets the section's flags. The flag is a 32 bit integer. The first bit (lowest) represents whether the section is currently enabled, the second bit represents whether the section is a subsection (don't modify this unless you really know what you are doing), the third bit represents whether the section is a subsection end (again, don't modify), the fourth bit represents whether the section is shown in bold or not, the fifth bit represents whether the section is read-only and the sixth bit represents whether the sub-section is to be automatically expanded. The error flag will be set if an out of range section is specified.
For an example of usage please see the
one-section.nsi example.


4.9.13.2 SectionGetFlags
section_index user_var(output)
Retrieves the section's flags. See above for a description of the flag. The error flag will be set if an out of range section is specified.


4.9.13.3 SectionSetText
section_index section_text
Sets the description for the section section_index. To set a subsection, you must use - at the beginning of the text. If the Text is set to "" than the section will be hidden. The error flag will be set if an out of range section is specified.


4.9.13.4 SectionGetText
section_index user_var(output)
Stores the text description of the section section_index into the output. If the section is hidden, stores an empty string. The error flag will be set if an out of range section is specified.


4.9.13.5 SectionSetInstTypes
section_index inst_types
Sets the install types the section specified by section_index defaults to the enabled state in. Note that the section index starts with zero. Every bit of inst_types is a flag that tells if the section is in that install type or not. For example, if you have 3 install types and you want the first section to be included in install types 1 and 3, then the command should look like this:
SectionSetInstTypes 0 5
because the binary value for 5 is "00000101". The error flag will be set if the section index specified is out of range.


4.9.13.6 SectionGetInstTypes
section_index user_var(output)
Retrieves the install types flags array of a section. See above explanation about SectionSetInstTypes for a description of how to deal with the output. The error flag will be set if the section index specified is out of range.


4.9.13.7 SectionSetSize
section_index new_size
Sets the Size of the section specified by section_index. Note that the Index starts with Zero. The Value for Size must be entered in KiloByte and supports only whole numbers.


4.9.13.8 SectionGetSize
section_index user_var
Gets the Size of the section specified by section_index and stores the value in the given User Variable. Note that the Index starts with Zero.


4.9.13.9 SetCurInstType
inst_type_idx
Sets the current InstType. The Error Flag is <b>not</b> set if an out of range InstType was used.


4.9.13.10 GetCurInstType
user_var
Get the current InstType and stores the Value in the given User Variable. The value of ${NSIS_MAX_INST_TYPES} (32 by default) means that the custom installation type was selected.


4.9.13.11 InstTypeSetText
inst_type_idx text
Sets the Text of the specified InstType. If the Text is empty than the InstType is removed. By using a previously unused inst_type_idx number you can create new InstTypes. To add/remove Sections to this new InstType see
SectionSetInstTypes . Unlike SectionIn the index is zero based, which means the first installation type's index is 0.


4.9.13.12 InstTypeGetText
inst_type_idx user_var
Gets the Text of the specified InstType.


4.9.14 User Interface Instructions



4.9.14.1 BringToFront
Makes the installer window visible and brings it to the top of the window list (i.e. if a command was executed that shows itself in front of the installer, a BringToFront would bring the installer back in focus).


4.9.14.2 CreateFont
user_var(handle output) face_name [height] [weight] [/ITALIC] [/UNDERLINE] [/STRIKE]
Creates a font and puts its handle into user_var. For more information about the different parameters have a look at
MSDN's page about the Win32 API function CreateFont() .


4.9.14.3 DetailPrint
user_message
Adds the string "user_message" to the details view of the installer.


4.9.14.4 EnableWindow
hwnd (1|0)
Enables or disables mouse and keyboard input to the specified window or control. Possible states are 0 (disabled) or 1 (enabled).


4.9.14.5 FindWindow
user_var(hwnd output) windowclass [windowtitle] [windowparent] [childafter]
Searches for a window. Behaves like the win32 FindWindowEx(). Searches by windowclass (and/or windowtitle if specified). If windowparent or childafter are specified, the search will be restricted as such. If windowclass or windowtitle is specified as "", they will not be used for the search. If the window is not found, the user variable returned is 0. To accomplish old-style FindWindow behavior, use FindWindow with SendMessage.


4.9.14.6 GetDlgItem
user_var(output) dialog item_id
Retrieves the handle of a control identified by item_id in the specified dialog box dialog. If you want to get the handle of a control on the inner dialog, first use FindWindow user_var(output) "#32770" "" $HWNDPARENT to get the handle of the inner dialog.


4.9.14.7 HideWindow
Hides the installer.


4.9.14.8 IsWindow
HWND jump_if_window [jump_if_not_window]
If HWND is a window, Gotos jump_if_window, otherwise, Gotos jump_if_not_window (if specified).


4.9.14.9 SendMessage
HWND msg wparam lparam [user_var(return value)] [/TIMEOUT=time_in_ms]
Sends a message to HWND. If a user variable $x is specified as the last parameter (or one before the last if you use /TIMEOUT), the return value of SendMessage will be stored to it. Note that when specifying 'msg' you must just use the integer value of the message. If you wish to send strings use "STR:a string" as wParam or lParam where needed.Include WinMessages.nsh to have all of Windows messages defined in your script.
To send a string param, put STR: before the parameter, for example: "STR:Some string".
Use /TIMEOUT=time_in_ms to specify the duration, in milliseconds, of the time-out period.


4.9.14.10 SetAutoClose
true|false
Overrides the default auto window-closing flag (specified for the installer using
AutoCloseWindow , and false for the uninstaller). Specify 'true' to have the install window immediately disappear after the install has completed, or 'false' to make it require a manual close.


4.9.14.11 SetBrandingImage
[/IMGID=item_id_in_dialog] [/RESIZETOFIT] path_to_bitmap_file.bmp
Sets the current bitmap file displayed as the branding image. If no IMGID is specified, the first image control found will be used, or the image control created by
AddBrandingImage . Note that this bitmap must be present on the user's machine. Use File first to put it there. If /RESIZETOFIT is specified the image will be automatically resized (very poorly) to the image control size. If you used AddBrandingImage you can get this size, by compiling your script and watching for AddBrandingImage output, it will tell you the size. SetBrandingImage will not work when called from .onInit!


4.9.14.12 SetDetailsView
show|hide
Shows or hides the details, depending on which parameter you pass. Overrides the default details view, which is set via
ShowInstDetails .


4.9.14.13 SetDetailsPrint
none|listonly|textonly|both|lastused
Sets mode at which commands print their status. None has commands be quiet, listonly has status text only added to the listbox, textonly has status text only printed to the status bar, and both enables both (the default). For extracting many small files, textonly is recommended (especially on win9x with smooth scrolling enabled).


4.9.14.14 SetCtlColors
hwnd [/BRANDING] [text_color] [transparent|bg_color]
Sets a background color and the text color for a static control, edit control, button or a dialog. Use GetDlgItem to get the handle (HWND) of the control. To make the control transparent specify "transparent" as the background color value. You can also specify /BRANDING with or without text color and background color to make the control completely gray (or any other color you choose). This is used by the branding text control in the MUI.


4.9.14.15 SetSilent
silent | normal
Sets the installer to silent mode or normal mode. See
SilentInstall for more information about silent installations. Can only be used in .onInit .
Sets the installer


4.9.14.16 ShowWindow
hwnd show_state
Sets the visability of a window. Possible show_states are the same as
Windows ShowWindow function. SW_* constants are defined in Include\WinMessages.nsh .


4.9.15 Multiple Languages Instructions



4.9.15.1 LoadLanguageFile
language_file.nlf
Loads a language file for the construction of a language table. All of the language files that come with NSIS are in
Contrib\Language Files For ease of use LoadLanguageFile defines ${LANG_language_file} as the language id. Use it with LangString , LangDLL and VIAddVersionKey .


4.9.15.2 LangString
name language_id string
Defines a multilingual string. This means the its value will be different (or not, it's up to you) for every language. It allows you to easily make your installer multilingual without the need to add massive switches to the script.
Each LangString has a name that identifies it and a value for each language used by the installer. To use a LangString you must know its name. LangStrings can be used in any runtime string in the script. To use a LangString all you need to add to the string is $(LangString_name_here) where you want the LangString to be inserted.
<b>Note:</b> Unlike defines that use curly braces - {}, multilingual strings use parenthesis - ().
For example, instead of:
StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
   MessageBox MB_OK "English message"
 StrCmp $LANGUAGE ${LANG_FRENCH} 0 +2
   MessageBox MB_OK "French message"
 StrCmp $LANGUAGE ${LANG_KOREAN} 0 +2
   MessageBox MB_OK "Korean message"
Use:
LangString message ${LANG_ENGLISH} "English message"
 LangString message ${LANG_FRENCH} "French message"
 LangString message ${LANG_KOREAN} "Korean message"
 MessageBox MB_OK "A translated message: $(message)"



4.9.15.3 LicenseLangString
name lang_id license_path
Does the same as
LangString only it loads the string from a text/RTF file and defines a special LangString that can be used only by LicenseData .


4.10 Multiple Languages
As of version 2 NSIS fully supports multiple languages. An installer can have more than one language. Each string in the installer can be easily translated using
LangString .
Each installer has one or more language tables which hold references to strings in the strings table. To create a language table all you need to do is use that language. Either use LoadLanguageFile or define a LangString and you have built your installer a language table. To make sure all of the inner strings NSIS uses are there you should load a language file using use LoadLanguageFile . The strings from the language file will be used as defaults in case you don't define some strings in the script. The language file strings can be used by the script too, not just internally by NSIS. Each string in the language file is assigned to a specific LangString. That LangString's name is listed as a comment just above the string in the English language file for your convenience. The language file is located in Contrib\Language Files .
For an example of usage see languages.nsi .


4.10.1 Language Selection
When the installer starts up it goes through these steps to select the interface language:Get user's default language (GetUserDefaultLangID()) into
Constant Variables Find a perfect match for the language id in Constant Variables If there is no perfect match, find a primary language matchIf there is no match, use the first language defined in the scriptIf Constant Variables has changed during .onInit, go through steps 2 to 4 again


4.10.2 LangDLL Plug-in
The LangDLL plug-in allows you to give the user an option to choose the language of the installer. Just push the language id (${LANG_*}) and its name for every language in your installer, then the number of languages pushed, the caption, and the text that tells the user to select the language, call the plug-in function named LangDialog, pop the returned value into $LANGUAGE and you're good to go. If the user clicks on the cancel button the return value will be "cancel".
For an example of usage see
languages.nsi .


4.10.3 RTL Languages
RTL languages are languages that are written from right to left. NSIS fully supports RTL languages. In the language file there is a place to specify if the language is RTL or not. If it is, NSIS will create another set of dialogs for the language that will be RTL. To find out on runtime if the language you're currently using is RTL or not check the value of the $(^RTL) language string. It will be 1 if the language is RTL and 0 otherwise.


4.11 Plugin DLLs
The abilities of the NSIS scripting language can be extended by utilising functionality provided in a DLL file. Probably the best known example of this is the InstallOptions.dll bundled with every NSIS release.
When the NSIS compiler starts it scans the plugins directory for DLLs and makes a list of the plugins found and their exported functions. During compilation if a sequence such as fred::flintstone is encountered where the compiler expected to find a language keyword the compiler will look through this list. If a list entry specifies that fred.dll exports function flintstone NSIS will pack the fred.dll file into the created installer binary.
During execution of the created installer if a plugin command is executed NSIS will unpack the necessary DLL to the $TEMP directory, push all of the arguments specified (right-to-left order), and then execute the DLL function. If the /NOUNLOAD option is specified the DLL will not be unloaded until the installer exits or the next time you use the DLL without /NOUNLOAD. Please note that the last call to the plugin must not have the /NOUNLOAD flag or the plugin will not be deleted from $PLUGINSDIR, thus garbage will be left on the user's machine.


4.11.1 Using Plugin Commands
The following two examples both invoke the same plugin command. The first example shows the (still okay) syntax that scripts written for versions of NSIS earlier than 2.0a4 had to use, and the second is how it can be scripted more succinctly now. The newer syntax automatically handles packing & extraction of the DLL file, and stacks up arguments for you too.
; Pre 2.0a4 syntax
SetOutPath $TEMP
GetTempFileName $8
File /oname=$8 InstallOptions.dll
Push "ini_file_location.ini"
CallInstDLL dialog
; Newer syntax
InstallOptions::dialog "ini_file_location.ini"
InstallOptions needs the name of it's ini file as a parameter to the dialog function so it has to be pushed onto the stack before the dialog call is made. Some plugin commands may not need any parameters on the stack, others might require two or three. To use a plugin command you will need to read the documentation for the plugin so that you know what parameters it's functions require, if any.


4.11.2 Disabling Plugin Unloading
CallInstDLL has an option not to unload the DLL after usage. To use it with the newer plugin command syntax just specify the first parameter as /NOUNLOAD. For example:
InstallOptions::dialog /NOUNLOAD "ini_file_location.ini"
You can also use
SetPluginUnload alwaysoff to avoid writing /NOUNLOAD each and every time you use the same plugin.

^ Top