Script Files

NSIS

Previous | Contents | Next

2.2 Script Files

To create a NSIS installer you first have to write a NSIS script. A NSIS script is just a regular text file with a special syntax. You can edit scripts with any text editor. It's recommended to use a text editor that shows line numbers because NSIS uses line numbers to indicate where errors lie, and to warn you about where errors might lie. An editor that supports syntax highlighting is also recommended. You can download editors made especially for NSIS and files for syntax highlighting from the NSIS Wiki.

In a NSIS script every line is treated as a command. If your command is too long for one line you can use a back-slash - '\' - at the end of the line. The compiler will treat the new line as an addition to the previous line and will not expect a new command. For example:

Messagebox MB_OK|MB_ICONINFORMATION \
"This is a sample that shows how to use line breaks for larger commands in NSIS scripts"

If you want to use a double-quote in a string you can either use $\" to escape the quote or quote the string with a different type of quote such as ` or '.

For more details about the script format, see Script File Format.

The default extension for a script file is .nsi. Header files have the .nsh extension. Header files can help you arrange your script by dividing it to more than one block of code, you can also put functions or macros in header files and include the header files in multiple installers. This makes updating easier and it also makes your scripts easier to read. To include a header file in your script use !include. Header files that reside in the Include directory under your NSIS directory can be included just by their name. For example:

!include Sections.nsh

Previous | Contents | Next