4. Scripting Reference<br>4.1 Script File Format

4. Scripting Reference
4.1 Script File Format

Browsing

Home: NSIS User Manual

Previous chapter: MakeNSIS Usage
Next chapter:
Scripting Reference

4.1 Script File Format
4.2 Instructions
4.3 Plugin DLLs
Chapters

0. Table of Contents
1. Introduction to NSIS
2. Tutorial: The Basics
3. MakeNSIS Usage
4. Scripting Reference
B. Useful Functions
Index
NSIS

Home page:NSIS

Documentation:User Manual
Modern UI
InstallOptions2

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]'
  • To call a plugin, use 'plugin::command [command parameters]'. For more info see Section 4.3 Plugin DLLs.
  • Anything after a ; or # that is not in a parameter (i.e. in quotes or part of another string) is treated as a comment. (e.g. "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, e.g. 0x12345AB), or octal (numbers beginning with a 0 and no x, e.g. 0377).
  • 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.
  • You can escape quotes using $\.
  • 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 ******!"`
     ; 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

  • 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.nsh" 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).

This page has been generated by
Scribe.
Last update Sat Apr 19 15:03:08 BST 2003