Script File Format

Nullsoft Scriptable Install System

Previous | Contents | Next

4.1 Script File Format

A NSIS Script File (.nsi) is just a text file with script code.

Commands

Commands lines are in the format 'command [parameters]'

File "myfile"

Comments

Lines beginning with ; or # are comments. You can put comments after commands. You can also use C-style comments to comment one or more lines.

; Comment
# Comment

# Comment \
    Another comment line (see `Long commands` section below)

/*
Comment
Comment
*/

Name /* comment */ mysetup

File "myfile" ; Comment

If you want a parameter to start with ; or # put it in quotes.

Plug-ins

To call a plug-in, use 'plugin::command [parameters]'. For more info see Plug-in DLLs.

nsExec::Exec "myfile"

Numbers

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

Colors should be set in hexadecimal RGB format, like HTML but without the #.

IntCmp 1 0x1 lbl_equal

SetCtlColors $HWND CCCCCC

Strings

To represent strings that have spaces, use quotes:

MessageBox MB_OK "Hi there!"

Quotes only have the property of containing a parameter if they surround the rest of the parameter. They can be either single quotes, double quotes, or the backward single quote.

You can escape quotes using $\:

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 happy!"` ; 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

It is also possible to put newlines, tabs etc. in a string using $\r, $\n, $\t etc. More information...

Variables

Variables start with $. User variables must be declared.

Var MYVAR

StrCpy $MYVAR "myvalue"

More information...

Long commands

To extend a command over multiple lines, use a backslash (\) at the end of the line. The next line will effectively be concatenated to the end of it. For example:

CreateShortcut "$SMPROGRAMS\NSIS\ZIP2EXE project workspace.lnk" \
    "$INSTDIR\source\zip2exe\zip2exe.dsw"

MessageBox MB_YESNO|MB_ICONQUESTION \
    "Do you want to remove all files in the folder? \
    (If you have anything you created that you want \
     to keep, click No)" \
    IDNO NoRemoveLabel

Line extension for long commands works for comments as well. It can be a bit confusing, so it should be avoided.

# A comment \
    still a comment here...

Configuration file

If a file named "nsisconf.nsh" in the config directory exists, it will be included by default before any scripts (unless the /NOCONFIG command line parameter is used). The config directory on Windows is the same directory as makensis.exe is in. On other platforms this is set at install time and defaults to $PREFIX/etc/. You can alter this at runtime, see section 3.1.3 for more information.

Previous | Contents | Next