Introduction to NSIS basic syntax

Source: Internet
Author: User

Introduction to NSIS basic syntax

 

Note

For single-row comments, use the "#" or Semicolon ";". For cross-row comments, use the comments syntax in c/C ++.

Data Type

Number

Numeric constants can be expressed in decimal, hexadecimal (0x as the prefix), and octal (0 as the prefix). The color is represented in RGB notation similar to that in html, but the decimal point "#" is used "#".

String

A String constant can be referenced in quotation marks, and the prefix of the conversion character is "$. $, $ N, $ r, $ t

Line feed

The nsi script uses the Backslash "" at the end of the line to indicate that the next row is logically the same as the current row.

Default header file

If there is an nsisconf. nsh file in the same directory of makensis, the file will be automatically included unless the/NOCONFIG option is specified during compilation.

Label

Nsi uses GOTO statements and IfErrors, MessageBox, IfFileExists and StrCmp to represent program control flows. labels are the target statements of these statements. Label definition Syntax:

The label must be defined in functions and segments. Its function scope is limited to defining its segments or functions. The label starting with "." is a global label.

Relative jump

Nsi scripts often use relative jumps to indicate condition branches. The syntax is [+-] [1-9]. the plus sign indicates that the current position is redirected forward, and the minus sign indicates that the current position is redirected backward. A number indicates the number of statements to jump. Example:

Goto + 4

MessageBox MB_ OK "The following message will be skipped"

Goto + 3

MessageBox MB_ OK "You will never ever see this message box"

Goto-3

MessageBox MB_ OK "Done"

Page

The Wizard Page is the most important interface element in the NSIS installation program. You can use the NSIS built-in page or custom interface in the nsi script to specify the page sequence, display appearance, and behavior. The Page command is used to define the Page in the installer, And the UninstPage command is used to define the Page. In addition, the PageEx command provides functions but more options. The order of the page is the same as that in the nsi script.

Page options

Different pages have different options:

The License page has LicenseText, LicenseData, and LicenseForceSelection;

The Components selection page contains ComponentText;

Directory selection pages include DirText, DirVar (only available in PageEx), DirVerify;

The Un/Installation log page contains DetailsButtonText and CompletedText;

The Uninstall confirmation page has DirVar (which can only be used in PageEx) and UninstallText

For built-in pages, NSIS supports three callback functions for custom interfaces and verification. For custom pages, NSIS supports two callback functions.

Page instruction syntax

Page license | components | directory | instfiles | uninstConfirm) [pre_function] [show_function] [leave_function]

Or:

Page custom [creator_function] [leave_function] [caption]

UninstPage command syntax

UninstPage custom [creator_function] [leave_function] [caption]

OR

UninstPage (license | components | directory | instfiles | uninstConfirm) [pre_function] [show_function] [leave_function]

PageEx syntax

Common nsi commands

Nsi can be divided into basic commands, registry and ini operation commands, General commands, process control commands, file operation commands, uninstall commands, string processing commands, multi-language support commands, and restart commands.

The following are common basic commands:

Delete

Delete [/REBOOTOK] file

Exec

Exec command

ExecShell

ExecShell action command [parameters] [SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED | SW_HIDE] ExecShell "open" example "http://XIAZAIBA.COM /"

ExecWait

ExecWait command [user_var (exit code)]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.