2002-11-15 18:45:47 +00:00
\C{scriptref} Scripting Reference
\H{fileformat} Script File Format
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
A NSIS Script File (.nsi) is just a text file with script code.
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
\\<b\\>Commands\\</b\\>
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
Commands lines are in the format 'command [parameters]'
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
\c File "myfile"
2002-10-28 16:40:34 +00:00
2004-01-23 10:50:26 +00:00
\\<b\\>Comments\\</b\\>
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
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.
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
\c ; Comment
\c # Comment
\c
\c /*
\c Comment
\c Comment
\c */
\c
2005-10-18 12:04:34 +00:00
\c Name /* comment */ mysetup
\c
2004-01-23 10:50:26 +00:00
\c File "myfile" ; Comment
2005-03-29 20:57:16 +00:00
If you want a parameter to start with ; or # put it in quotes.
2004-01-23 10:50:26 +00:00
\\<b\\>Plug-ins\\</b\\>
2005-07-29 15:08:32 +00:00
To call a plug-in, use 'plugin::command [parameters]'. For more info see \R{plugindlls}{Plug-in DLLs}.
2004-01-23 10:50:26 +00:00
\c nsExec::Exec "myfile"
\\<b\\>Numbers\\</b\\>
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 #.
\c IntCmp 1 0x1 lbl_equal
\c
\c SetCtlColors $HWND CCCCCC
\\<b\\>Strings\\</b\\>
To represent strings that have spaces, use quotes:
\c MessageBox MB_OK "Hi there!"
Quotes only have the property of containing a parameter if they begin the parameter. They can be either single quotes, double quotes, or the backward single quote.
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
You can escape quotes using $\\:
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
\c MessageBox MB_OK "I'll be happy" ; this one puts a ' inside a string
\c MessageBox MB_OK 'And he said to me "Hi there!"' ; this one puts a " inside a string
2005-10-26 19:01:13 +00:00
\c MessageBox MB_OK `And he said to me "I'll be happy!"` ; this one puts both ' and "s inside a string
2004-01-23 10:50:26 +00:00
\c MessageBox MB_OK "$\"A quote from a wise man$\" said the wise man" ; this one shows escaping of quotes
2002-11-21 19:15:32 +00:00
2004-01-24 16:35:24 +00:00
It is also possible to put newlines, tabs etc. in a string using $\\r, $\\n, $\\t etc. \R{varstrings}{More information...}
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
\\<b\\>Variables\\</b\\>
2002-09-02 18:05:40 +00:00
2005-06-30 19:51:26 +00:00
Variables start with $. User variables should be declared.
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
\c Var MYVAR
\c
\c StrCpy $MYVAR "myvalue"
\R{variables}{More information...}
\\<b\\>Long commands\\</b\\>
2002-09-02 18:05:40 +00:00
2005-03-29 20:57:16 +00:00
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:
2004-01-23 10:50:26 +00:00
\c CreateShortCut "$SMPROGRAMS\NSIS\ZIP2EXE project workspace.lnk" \
\c "$INSTDIR\source\zip2exe\zip2exe.dsw"
2002-09-02 18:05:40 +00:00
\c
2004-01-23 10:50:26 +00:00
\c MessageBox MB_YESNO|MB_ICONQUESTION \
\c "Do you want to remove all files in the folder? \
\c (If you have anything you created that you want \
\c to keep, click No)" \
\c IDNO NoRemoveLabel
\\<b\\>Configuration file\\</b\\>
2002-09-02 18:05:40 +00:00
2004-01-23 10:50:26 +00:00
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).