## NSIS

### Table of Contents

- Features
- MakeNSIS usage
- .NSI script format
  - Installer attributes
  - Compiler flags
  - Sections
  - Functions
  - Labels
  - Instructions
    - Basic: SetOutPath, File, Exec, ExecWait, ExecShell, Rename, Delete, RMDir.
    - Registry/INI: WriteRegStr, WriteRegExpandStr, WriteRegDWORD, WriteRegBin, WriteINIStr, ReadRegStr, ReadRegDWORD, ReadINIStr, ReadEnvStr, ExpandEnvStrings, DeleteRegValue, DeleteRegKey, EnumRegKey, EnumRegValue, DeleteINISec, DeleteINIStr.
    - Advanced: CreateDirectory, CopyFiles, SetFileAttributes, CreateShortCut, GetFullPathName, SearchPath, GetTempFileName, CallInstDLL, RegDLL, UnRegDLL, GetDllVersion, GetDLLVersionLocal, GetFileTime, GetFileTimeLocal.
    - Branching/etc: Goto, Call, Return, IfErrors, ClearErrors, SetErrors, FindWindow, SendMessage, IsWindow, IfFileExists, MessageBox, StrCmp, IntCmp, IntCmpU, Abort, Quit, GetFunctionAddress, GetLabelAddress, GetCurrentAddress.
    - File/directory i/o: FindFirst, FindNext, FindClose, FileOpen, FileClose, FileRead, FileWrite, FileReadByte, FileWriteByte, FileSeek.
    - Misc: SetDetailsView, SetDetailsPrint, SetAutoClose, DetailPrint, Sleep, BringToFront, HideWindow.
    - Strings: StrCpy, StrLen.
    - Stack: Push, Pop, Exch.
    - Integers: IntOp, IntFmt.
    - Reboot: Reboot, IfRebootFlag, SetRebootFlag.
    - Uninstall: WriteUninstaller.
  - Variables
  - Uninstall section
  - Callback functions
  - Compiler utility commands
  - Compiler defines/conditional compilation
- Version history
- License

### Features

- SuperPiMP™ technology (so advanced, so amazing, we won't even tell you what it is).
- Generates self contained, win32 executable installer.
- Uninstall support (installer can automagically generate an uninstaller)
- Optional installer self-verification using a CRC32.
- Compression choices of zlib or bzip2 based compression. The installer can compress everything together, or individually.
- Approximately 20-40k overhead over compressed data size (depending on features enabled, compression algorithm, and so on - the default options are ~35k).
- Ability to display a license agreement.
- Ability to detect destination directory from the registry, and let the user override (or not let them)
- Customizable appearance (background, icons, text, checkmarks)
- Multiple install configurations (usually Minimal, Typical, Full), and custom configuration
- Installers can be as large as 2GB (theoretically -- when building on Win9x the limit seems to be around 500MB, however building on NT then installing on Win9x works with larger sizes)
- Optional Silent mode for automated installations
- Installers have their own VMs that let you write code that can support:
  - File extraction (with configurable overwrite parameters)
  - File/directory copying, renaming, deletion
  - DLL loading (ActiveX control registration/deregistration, extension DLL calling, etc)
  - Executable execution (shell execute and wait options)
  - Shortcut creation
  - Registry key reading/setting/enumerating/deleting
  - INI file reading/writing
  - Generic text file reading/writing
  - Directory scanning
  - Powerful string and integer manipulation
  - Window finding based on class name or title (for is-application-running detection)
  - Window message sending.
  - User interaction with MessageBox.
  - Branching, comparisons, etc.
  - Error checking.
  - Installer behaviour commands (such as show/hide/wait/etc)
  - User functions in script
  - Callback functions that let you customize the way the installer behaves from script.
  - A lovely coding experience with elements of PHP and assembly.
  - More
- Completely free for any use. Source included. See license.

### MakeNSIS usage

NSIS installers are generated by using the 'MakeNSIS' program to compile a NSIS script (.NSI) into an installer executable. The syntax of the makensis command is:

    Makensis [/Vx] [/Olog] [/LICENSE] [/PAUSE] [/NOCONFIG] [/CMDHELP [command]] [/HDRINFO] [/CD]
             [/Ddefine[=value] ...] ["/XCommand parameter" ...] [Script.nsi | - [...]]

- /LICENSE displays a keen license page.
- The /V switch followed by a number between 0 and 4 will set the verbosity of output accordingly. 0=no output, 1=errors only, 2=warnings and errors, 3=info, warnings, and errors, 4=all output.
- The /O switch followed by a filename tells the compiler to print its log to that file (instead of the screen)
- /PAUSE makes Makensis pause before quitting, which is useful when executing directly from Windows (the auto-installed shell extensions use it).
- /NOCONFIG disables inclusion of [path to makensis.exe]\nsisconf.nsi . Without this parameter, installer defaults are set from nsisconf.nsi. See NSIS Configuration File.
- /CMDHELP prints basic usage information for command (if specified), or all commands (if command is not specified).
- /HDRINFO prints out information on what options Makensis was compiled with.
- /CD tells the compiler to switch to the directory of the script it is currently compiling.
- Using the /D switch one or more times will add to symbols to the globally defined list (See !define).
- Using the /X switch one or more times will execute the code you specify following it. Example: "/XAutoCloseWindow false"
- Specifying a dash (-) for the script name will tell Makensis to use the standard input as a source.
- If multiple scripts are specified, they are treated as one concatenated script.

Note that the NSIS development kit installer may have set up your computer so that you can compile a .nsi file by simply right-clicking on it in explorer, and selecting 'compile'.

### .NSI script format

A NSIS Script File (.nsi) is just a text file with a series of commands.

- Lines beginning with ; or # are comments.
- Non-comment lines are in the form of 'command [parameters]'
- Anything after a ; or # that is not in a parameter (i.e. in quotes or part of another string) is treated as a comment. (i.e. "File myfile ; this is the file" would work)
- For parameters that are treated as numbers, use decimal (the number) or hexadecimal (with 0x prepended to it, i.e. 0x12345AB), or octal (numbers beginning with a 0 and no x).
- To represent strings that have spaces, use quotes.
  - quotes only have the property of containing a parameter if they begin the parameter.
  - quotes can be either single quotes, double quotes, or the backward single quote.
  Examples:

          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:

  It's a little weird, I know, but oh well.
- To extend a command over multiple lines, use a backslash (\) at the end of the line, and the next line will effectively be concatenated the end of it. For example:

          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

- If a file named "nsisconf.nsi" in the same directory as makensis.exe exists, it will be included by default before any scripts (unless the /NOCONFIG command line parameter is used.
- To have a template .nsi generated to your needs, go here.

#### Installer 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.

General installer configuration
OutFile | 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 effect the contents of the installer.
Name | name | Sets the name of the installer. The name is usually simply the product name such as 'MyApp' or 'CrapSoft MyApp'.
Caption | caption | Sets what the titlebars of the installer will display. By default, it is 'Name Setup', where Name is specified with the Name command. 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)
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)
BrandingText | 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.
Icon | path_to_icon.ico | Sets the icon of the installer. The icon MUST contain a 32x32x16 color icon resource (it can also contain other icons, but they will be discarded).
WindowIcon | on|off | Sets whether or not the installer's icon is in the upper left corner of the installer.
BGGradient | [off]| [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.
SilentInstall | normal| silent| silentlog | Specifies whether or not the installer should be silent. If it is 'silent' or 'silentlog', all sections are installed quietly, 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 on the command line, it will behave as if SilentInstall 'silent' was used.
SilentUnInstall | normal| silent | Specifies whether or not the uninstaller should be silent.
CRCCheck | on|off | Specifies whether or not the installer will perform a CRC on itself before allowing an install. Valid options are 'on' and 'off'. Note that if the user uses /NCRC on the command line when executing the installer, the CRC will not occur, and the user will be allowed to install a (potentially) corrupted installer.
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.
InstallButtonText | [install button text] | If parameter is specified, overrides the default install button text (of "Install") with the specified text.
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.".
Install directory configuration
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.
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.
License page configuration
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".
LicenseData | licdata.txt | Specifies a text 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!)
Component page configuration
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 " ".
InstType | install_type_name | /NOCUSTOM | /CUSTOMSTRING=str| /COMPONENTS.. ..ONLYONCUSTOM | Adds an install type to the install type list, or disables the custom install type. There can be as many as 8 types, each one specifying the name of the install. 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 shown if the "Custom" install type is selected.
EnabledBitmap | bitmap.bmp | Sets the enabled state of the listbox for the component page. It MUST be a 16 color bitmap (it can be any size, but 20x20 is preferred -- all others will be resized down... poorly).
DisabledBitmap | bitmap.bmp | Sets the disabled state of the listbox for the component page. It MUST be a 16 color bitmap (it can be any size, but 20x20 is preferred -- all others will be resized down... poorly).
SpaceTexts | [req text] [avail text] | If parameters are specified, overrides the space required and space available text ("Space required: " and "Space available: " by default).
Directory page configuration
DirShow | show|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).
DirText | [text] [subtext] [browse text] | 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). If subtext is specified and not empty, it overrides the default text above the path entry box ("Select the directory to install MyApp in:"). If browse button text is specified but not empty, it overrides the default browse button text ("Browse...").
AllowRootDirInstall | true|false | 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 default (safe) behavior, which prevents users from selecting C:\ or \\server\share as an install (and lataer on, uninstall) directory.
|  | For additional directory selection page customizability, see .onVerifyInstDir
Install page configuration
InstallColors | /windows | foreground background | 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.
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).
AutoCloseWindow | true|false | Sets whether or not the install window automatically closes when completed. Can be 'false' or 'true'. This is overrideable from a section using SetAutoClose.
ShowInstDetails | hide|show|nevershow | Sets whether or not the details of the install are shown. Can be 'hide' (the default) 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.
DetailsButtonText | [show details text] | Replaces the default details button text of "Show details", if parameter is specified (otherwise the default is used).
CompletedText | [Completed text] | Replaces the default text ("Completed") that is printed at the end of the install if parameter is specified. Otherwise, the default is used.
Uninstall configuration
| 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:".
UninstallIcon | path_to_icon.ico | Sets the icon of the uninstaller. Again, the icon MUST contain a 32x32x16 color icon resource (it can also contain other icons, but they will be discarded).
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)
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)
ShowUninstDetails | hide | show | nevershow | Sets whether or not the details of the uninstall are shown. Can be 'hide' (the default) 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.
UninstallButtonText | [button 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).

#### 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 overriden by another command).

SetOverwrite | on|off|try|ifnewer | 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 (note that when in 'ifnewer' mode, the destination file's date is set, regardless of what SetDateSave is set to).
SetCompress | auto|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).
SetDatablockOptimize | on|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).
SetDateSave | on|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.

#### Sections:

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

- Each section contains zero or more instructions.
- Sections are executed in order by the resulting installer, and if ComponentText is set, the user will have the option of disabling/enabling each section.
- If a section's name is 'Uninstall', then it is a special Uninstall Section.

Section | [section_name] | Begins annd opens a new section. If section_name is empty, omitted, or begins with a -, then it is a required section and the user will not see it, nor have the option of disabling it. If the section name is 'Uninstall', then it is a special Uninstall Section.
SectionIn | section_index_list | This command specifies which Install Types (see InstType) the current section defaults to the enabled state in. You can specify numbers, with any characters (or none) delimiting (i.e. 1258 or 1,2,5,8 or 1-2-5-8 or 1 2 5 8 all do the same thing). Alternatively, multiple SectionIn commands can be specified (they are combined).
SectionEnd |  | This command closes the current open section.
SectionDivider | [divider caption] | This command inserts a divider into the section list that the user sees. If a divider caption is specified, it will be shown on the divider.
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).

#### Functions:

Functions are like similar to Sections in that they contain zero or more instructions. Functions are not called by the installer directly, instead they are called from Sections using the Call instruction (Note: there are some special Callback Functions that can be called by the installer directly).

- Functions must be declared outside of Sections or other Functions.
- 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.

Function | function_name | Creates and opens a function named function_name.
FunctionEnd |  | Ends the current open function.

See also: Utility Functions (functions.htm).

#### 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 accessable 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).

#### 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 22 registers (20 general purpose, 2 special purpose), and a stack.

General purpose, basic instructions
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 "-").
File | ([/r] file|wildcard [...]) | (/oname=file.dat infile.dat) | Adds file(s) to be extracted to the current output path ($OUTDIR). Note that the output file name is $OUTDIR\filename_portion_of_file. If the /oname=X switch is used, the output name becomes $OUTDIR\X. When using the /oname= switch, only one file can be specified, and the file name can contain variables (or a fully qualified path, i.e. $SYSDIR\whatever.dll). Wildcards are supported. If the /r switch is used, files and directories are added recursively. If is no trailing wildcard (i.e. File /r C:\whatever\mydir), then the whole tree of mydir will go in $OUTDIR\mydir. To put it in $OUTDIR, use File /r C:\whatever\mydir\*.* The File command sets the error flag if overwrite mode is set to 'try' and the file could not be overwritten, or if the overwrite mode is set to 'on' and the file could not be overwritten and the user selects ignore.
Exec | command | Execute the specfied 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 may with to put it in quotes to delimit it from parameters. i.e.: Exec '"$INSTDIR\command.exe" parameters'.
ExecWait | command [user_var(exit code)] | Execute the specfied 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 may with to put it in quotes to delimit it from parameters. i.e.: ExecWait '"$INSTDIR\command.exe" parameters'
ExecShell | action command [parameters] [SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED] | Execute the specfied 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.
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. If /REBOOTOK is specified, and the file cannot be overwritten, 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.
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.
RMDir | [/r] directory | Remove the directory (which should be a full path). If /r is specified, it will recursively remove the directory. The error flag is set if the directory exists and cannot be removed.
Registry, INI file reading/writing/deleting instructions
WriteRegStr WriteRegExpandStr | root_key subkey key_name value | Write a string to the registry. root_key must be one of: HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS HKCC or HKEY_CURRENT_CONFIG HKDD or HKEY_DYN_DATA HKPD or HKEY_PERFORMANCE_DATA 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.
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.
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 (i.e. DEADBEEF01223211151). The error flag is set if the binary data could not be written to the registry.
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.
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.
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.
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.
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.
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.
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).
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).
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.
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.
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.
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.

General purpose, advanced instructions
CreateDirectory path_to_create Creates (recursively if necessary) the specified directory.
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.
SetFileAttributes filename attribute1|attribute2|... Sets the file attributes of 'filename' (which can contain wildcards). Valid attributes can be combined with | and are:

- NORMAL or FILE_ATTRIBUTE_NORMAL (you can use 0 to abbreviate this)
- ARCHIVE or FILE_ATTRIBUTE_ARCHIVE
- HIDDEN or FILE_ATTRIBUTE_HIDDEN
- OFFLINE or FILE_ATTRIBUTE_OFFLINE
- READONLY or FILE_ATTRIBUTE_READONLY
- SYSTEM or FILE_ATTRIBUTE_SYSTEM
- TEMPORARY or FILE_ATTRIBUTE_TEMPORARY

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)
CreateShortCut link.lnk
target.file
[parameters]
[icon.file]
[icon_index_number]
[start_options]
[keyboard_shortcut] 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.

The error flag is set if the shortcut cannot be created (i.e. the path does not exist, or some other error).
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.
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.
GetTempFileName user_var(output) 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. Delete the file when done with it.
CallInstDLL dllfile
function Calls a NSIS extension DLL. See Contrib\ExDLL for an example of how to make one. Extension DLLs can access the stack and variables.
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, or find the entry point).
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, or find the entry point).
GetDLLVersion filename
user_var(high dword output)
user_var(low dword output) Gets the version information from the DLL 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.
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.
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.
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.
Branching, flow control, error checking, user interaction, etc instructions
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. I Compiler flag commands and SectionIn aren't instructions so jumping over them has no effect.
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).
Return Returns from a function or section.
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.
ClearErrors Clears the error flag.
SetErrors Sets the error flag.
FindWindow user_var(hwnd output)
windowclass
[windowtitle]
[windowparent]
[childafter] Searches for a window. Behaves like the win32 FindWindowEx(). Seaches 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.
SendMessage HWND
msg
wparam
lparam
[user_var(return value)] Sends a message to HWND. If a user variable $x is specified as the last parameter, 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. Here are a few example messages and their values:

- WM_CLOSE 16
- WM_COMMAND 273
- WM_USER 1024

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).
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\*.*
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 (i.e. MB_YESNO|MB_ICONSTOP).

- MB_OK - Display with an OK button
- MB_OKCANCEL - Display with an OK and a cancel button
- MB_ABORTRETRYIGNORE - Display with abort, retry, ignore buttons
- MB_RETRYCANCEL - Display with retry and cancel buttons
- MB_YESNO - Display with yes and no buttons
- MB_YESNOCANCEL - Display with yes, no, cancel buttons
- MB_ICONEXCLAMATION - Display with exclamation icon
- MB_ICONINFORMATION - Display with information icon
- MB_ICONQUESTION - Display with question mark icon
- MB_ICONSTOP - Display with stop icon
- MB_TOPMOST - Make messagebox topmost
- MB_SETFOREGROUND - Set foreground
- MB_RIGHT - Right align text
- MB_DEFBUTTON1 - Button 1 is default
- MB_DEFBUTTON2 - Button 2 is default
- MB_DEFBUTTON3 - Button 3 is default
- MB_DEFBUTTON4 - Button 4 is default

return_check can be 0 (or empty, or left off), or one of the following:

- IDABORT - Abort button
- IDCANCEL - Cancel button
- IDIGNORE - Ignore button
- IDNO - No button
- IDOK - OK button
- IDRETRY - Retry button
- IDYES - Yes button

if the return value of the MessageBox is return_check, the installer will Goto jumpto.
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.
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.
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.
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. Note 2: When using from .onNextPage or .onPrevPage, the parameter to Abort can be an integer that specifies how many pages to skip.
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).
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).
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.
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.
File and directory i/o instructions
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.
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.
FindClose handle Closes a search opened with FindFirst.
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.
FileClose handle Closes a file handle opened with FileOpen.
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.
FileWrite handle
string Writes a string to a file opened with FileOpen. If an error occurs writing, the error flag will be set.
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.
FileWriteByte handle
string Writes the integer interpretation of 'string' to a file opened with FileOpen. 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.
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.
Misc instructions
SetDetailsView show|hide Shows or hides the details, depending on which parameter you pass. Overrides the default details view, which is set via ShowInstDetails
SetDetailsPrint none |
listonly |
textonly |
both 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).
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.
DetailPrint user_message Adds the string "user_message" to the details view of the installer.
Sleep sleeptime_in_ms Pauses execution in the installer for sleeptime_in_ms milliseconds. sleeptime_in_ms can be a variable, i.e. "$0" or a number, i.e. "666".
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).
HideWindow Hides the installer.
String manipulation support
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).
StrLen user_var(length output)
str Sets user variable $x with the length of str.
Stack support
Push string Pushes a string onto the stack. The string can then be Popped off of the stack.
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.
Exch [user_var] |
stack_index When no parmater 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, the parameter specifies which item on the stack that the top of the stack is swapped with. If there are not enough items on the stack to accomplish the exchange, a fatal error will occur (to help you debug your code :).
Integer manipulation support
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:

- + ADDs value1 and value2
- - SUBTRACTs value2 from value1
- * MULTIPLIES value1 and value2
- / DIVIDEs value1 by value2
- % MODULUSs value1 by value2
- | BINARY ORs value1 and value2
- & BINARY ANDs value1 and value2
- ^ BINARY XORs value1 and value2
- ~ BITWISE NEGATEs value1 (i.e. 7 becomes 4294917288)
- ! LOGICALLY NEGATEs value1 (i.e. 7 becomes 0)
- || LOGICALLY ORs value1 and value2
- && LOGICALLY ANDs value1 and value2

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" etc.
Rebooting support
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 sucessful, this instruction does not return.
IfRebootFlag [jump_if_set]
[jump_if_not_set] 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.
SetRebootFlag true|false Sets the reboot flag to either true or false.
Uninstaller instructions
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.

#### Variables:

The following are modifiable variables that are usable in Instructions:
$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)
$0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $R0, $R1, $R2, $R3, $R4, $R5, $R6, $R7, $R8, $R9 | User variables (set via StrCpy, ReadRegStr, ReadINIStr, etc, and use like any other variable). It is recommended (but not required) that you use $R1-$R9 as local registers, and $0-$9 as global values. Note that any function that lets you specify one of these variables as an output, can use $INSTDIR or $OUTDIR as well (but has different implications).
$CMDLINE | The command line of the installer. The format of the command line can be one of the following: "full\path to\installer.exe" PARAMETER PARAMETER PARAMETER installer.exe PARAMETER PARAMETER PARAMETER For parsing out the PARAMETER portion, see GetParameters on the utility functions page. It's worth noting that if /D= is specified on the command line (to override the install directory), it won't be in $CMDLINE.
The following are constant variables that are usable in Instructions and InstallDir:
$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).
$EXEDIR | The location of the installer executable. (technically you can modify this variable, but it is probably not a good idea)
$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)
$SMPROGRAMS | The start menu programs folder (use this whenever you want $STARTMENU\Programs)
$SMSTARTUP | The start menu programs / startup folder
$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.
$$ | Use to represent $.
The following "variables" are usable anywhere in a string:
$\r | Use to represent a carriage return (\r).
$\n | Use to represent a newline (\n).
${SYMBOL} | Where SYMBOL is the name of something globally defined, this will be replaced with the value of that symbol. If the symbol is not defined, no replace occurs (i.e. if ${POOP} is encountered, and POOP is not defined, ${POOP} is output).

#### 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 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.

#### 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:

Install callbacks
.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
.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
.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 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
.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
.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
.onNextPage | Called when the user selects to go from one page to the next. Also called when the first page is shown (after .onInit). Call Abort from this callback in order to make the installer stay on the current page (or to make it move relative to the current page - Abort 0 means to stay put, Abort 1 means to go to the next page, Abort 2 means to go to the following page, Abort -1 means to go back a page, and so on). To figure out which page you are on, you can just keep a counter and increment it on .onNextPage, and decrement it on .onPrevPage. Note that if the directory selection page is disabled, .onNextPage and .onPrevPage are still called for it. Example use of .onNextPage/.onPrevPage/.onInit:
    Function .onInit
      StrCpy $9 0 ; we start on page 0
    FunctionEnd

    Function .onNextPage
      StrCmp $9 1 "" noabort
        MessageBox MB_YESNO "advance to the second page?" IDYES noabort
          Abort
      noabort:
        IntOp $9 $9 + 1
    FunctionEnd

    Function .onPrevPage
      StrCmp $9 2 "" noabort
        MessageBox MB_YESNO "go back to the first page?" IDYES noabort
          Abort
      noabort:
        IntOp $9 $9 - 1
    FunctionEnd
.onPrevPage | Called when the user selects to go from one page to the previous. Call Abort from this callback in order to make the installer stay on the current page (or pass an integer parameter to Abort to specify how many pages to move: Abort 1 means to go back one page, Abort 2 means to go back two pages, Abort -1 means to go forward a page, and so on). See .onNextPage for more information.
Uninstall callbacks
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
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
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 AutoCloseWindow is set to false). Example:
      Function un.onUninstSuccess
        MessageBox MB_OK "Congrats, it's gone."
      FunctionEnd
un.onUninstFailed | This callback is called when the user hits the 'cancel' button after the uninstall has failed (if it used the Abort command or otherwise failed). Example:
      Function un.onUninstFailed
        MessageBox MB_OK "Better luck next time."
      FunctionEnd
un.onNextPage | Called when the user selects 'Uninstall' or 'Close' from the uninstaller. Call Abort from this callback in order to make the uninstaller stay on the current page.

#### Compiler utility commands

These commands are similar to the C preprocessor in terms of purpose and functionality. They allow file inclusion, conditional compilation, executable header packing, and processes execution during the build process. Note: none of these commands allow use of variables.

!system | command [compare comparevalue] | This command will execute 'command' using a call to system(), and if the return value compared (using 'compare') to 'comparevalue' is false, execution will halt. 'compare' can be '<' or '>' or '<>' or '=' or 'ignore'.
!include | file | This command will include 'file' as if it was part of the original script. Note that if a file is included in another directory, the current directory is still where the script was compiled from (not where the included file resides).
!cd | new_path | This command will change the compiler to the new directory, new_path. new_path can be relative or absolute.
!packhdr | tempfile command | This option makes the compiler an external EXE packer (such as Petite or UPX) to compress the executable header. Specify a temporary file name (such as "temp.dat") and a command line (such as "C:\program files\upx\upx -9 temp.dat") to compress the header.

### Compiler defines/conditional compilation:

The compiler maintains a list of defined symbols, which can be defined using !define or the /D command line switch. These defined symbols can be used for conditional compilation (using !ifdef) or for symbol replacement (a simple form of macros). To replace a symbol with its value, use ${SYMBOL} (if SYMBOL is not defined, no translation will occur). The translation is first-come-first-served, meaning if you do:
!define symbol1 ${symbol2}
if symbol2 is defined when that line occurs, it will be replaced. Otherwise, any replacing will occur when ${symbol1} is referenced.
Define/conditional compilation related commands:

!define | gflag [value] | This command will add 'gflag' to the global define list. This will have a similar effect as using the /D switch on the command line (only the define only becomes effective after the !define command).
!undef | gflag | Removes an item from the global define list. Note that ${SYMBOL} where SYMBOL is undefined will be translated to "${SYMBOL}".
!ifdef | gflag [bcheck [gflag [...]]] | This command, when paired with an !endif command, will tell the compiler whether or not to compile the lines in between the two lines. If gflag is globally defined (using !define or the /D switch), then the contained lines will be compiled. Otherwise, they will be skipped. 'bcheck' can be specified as & (boolean and) or | (boolean or) along with more gflags -- precedence is simple, left to right.
!ifndef | gflag [bcheck [gflag [...]]] | This command is the opposite of !ifdef (If 'gflag' is not globally defined, the lines contained will be compiled). Note that when using boolean operators (& or |), 'gflag' is treated as true if it is undefined. I.e. '!ifndef X | Y' means "if either X or Y is undefined" and '!ifndef X & Y' means "if X and Y are both undefined".
!endif |  | This command closes a block started with !ifdef or !ifndef.
!else | [ifdef|ifndef [...]] | This command is the logical lovemonkey to !ifdef and !endif. !ifdef/!else/!endif, !ifdef/!else ifdef/!endif, !ifdef/!else ifdef/!else ifndef/!endif, etc. If ifdef or ifndef is specified as the first parameter, it behaves as expected.
!macro | macro_name | Creates a macro named 'macro_name'. All lines between the !macro and the !macroend will be saved. To insert the macro later on, use !insertmacro. Note that macros cannot contain other macro definitions (though they can insert other macros), or !ifdef/!else/!endif.
!macroend |  | Ends a macro that was started with !macro.
!insertmacro | macro_name | Inserts the contents of a macro that was created with !macro.

### Version history:

- v1.96
  - Removed a few documentation errors (happy now, Alex??)
  - Updated to the latest makensisw.exe (sexy!)
  - Fixed a resource.h issue (thanks Robert Rainwater)
  - Fixed compilation bug when logging enabled (thanks Fritz Elfert)
  - Fixed bug in Call when calling a variable location from uninstall (thanks to Fritz Elfert again)
- v1.95
  - Fixed section divider bug (thanks to Robert Rainwater)
  - Included a modified version of MakeNSISW (thanks to Robert Rainwater)
  - Made compiler's output line display full path (for the wrapper)
- v1.94
  - Fixed whole compression + small uninstaller bug.
- v1.93
  - Made !insertmacro work within macros and in command mode.
  - Removed stupid CRC padding on tiny installers (also fixes whole+CRC+tinyinstaller bug).
  - Other cleanups to both build output and exehead.
  - Zip2exe v0.16 (yay)
- v1.92
  - Fixed bug in InstallOptions (State= empty on checkboxes causing problems)
  - Included WinMessages.NSH from KiCHiK
  - Added NSIS_COMPRESS_BZIP2_LEVEL option to config.h
  - Made compiler fflush() more often.
  - Made zip2exe use Miguel Garrido's code to embed the console instance of makensis (well, modified it a bit too).
  - Made zip2exe allow selection of makensis.exe (so you can do makensis-bz2.exe if you want), and have lots of other improvements.
- v1.91
  - Made GetFileTime handle locked files better (thanks Dave Bau).
  - Cleaned up exec.c some by making file_exists() return metadata about the file.
  - Removed any versioning issues with the multiple 1.90s (since I'm stupid and make multiple versions with the same number).
- v1.90
  - Included Install Options DLL instead of the classic install options.
  - Added GetTempFileName instruction.
  - Dave Laundon's new onNextPage/onPrevPage style.
- v1.9b2
  - Included Peter Windridge's Delphi ExDLL port (contrib\exdll\exdll.dpr)
  - Added Quit instruction (almost instantly quits installer).
  - Added .onNextPage, .onPrevPage, and un.onNextPage callbacks.
- v1.9b
  - Support for bzip2 as well as zlib for compression (see config.h - the default distribution includes makensis.exe (classic support) and makensis-bz2.exe (new style, can make smaller installers))
  - Support for compression that spans the entire installer (see config.h - the makensis-bz2.exe uses this by default) -- expense of temporary file required.
  - Included contrib\nsisdl (thanks, Yaroslav - updated again)
  - Began making more install strings changeable (see lang.h). Soon (for 2.0 hopefully) we will have full multilanguage (multiple languages per installer) support.
  - Fun command line updates.
- for complete version history, see http://www.nullsoft.com/free/nsis/version-history.html.

### License:

     Copyright (C) 1999-2001 Nullsoft, Inc.

      This software is provided 'as-is', without any express or implied
      warranty.  In no event will the authors be held liable for any damages
      arising from the use of this software.

      Permission is granted to anyone to use this software for any purpose,
      including commercial applications, and to alter it and redistribute it
      freely, subject to the following restrictions:

      1. The origin of this software must not be misrepresented; you must not
         claim that you wrote the original software. If you use this software
         in a product, an acknowledgment in the product documentation would be
         appreciated but is not required.
      2. Altered source versions must be plainly marked as such, and must not be
         misrepresented as being the original software.
      3. This notice may not be removed or altered from any source distribution.

eof (that's end of file for all you people who don't get it).