3.1 MakeNSIS Usage
NSIS installers are generated by using the 'MakeNSIS' program to compile a NSIS script (.NSI) into an installer executable. The NSIS development kit installer sets up your computer so that you can compile a .nsi file by simply right-clicking on it in Explorer and selecting 'compile'.
If you want to use MakeNSIS on the command line, the syntax of makensis is:
makensis [ option | script.nsi | - ] [...]
3.1.1 Options
/LICENSEdisplays license information.- The
/Vswitch followed by a number between 0 and 4 will set the verbosity of output accordingly. 0=no output, 1=errors only, 2=warnings and errors, 3=info, warnings, and errors, 4=all output. - The
/Pswitch followed by a number between 0 and 5 will set the priority of the compiler process accordingly. 0=idle, 1=below normal, 2=normal (default), 3=above normal, 4=high, 5=realtime. - The
/Oswitch followed by a filename tells the compiler to print its log to that file (instead of the screen) /LAUNCHexecutes the generated installer./PAUSEmakes makensis pause before quitting, which is useful when executing directly from Windows./NOCONFIGdisables inclusion ofnsisconf.nsh. Without this parameter, installer defaults are set fromnsisconf.nsh./CMDHELPprints basic usage information for command (if specified), or all commands (if command is not specified)./HDRINFOprints information about which options were used to compile makensis./NOCDdisables the current directory change to that of the.nsifile/INPUTCHARSETallows you to specify a specific codepage for files without a BOM. (ACP|OEM|CP#|UTF8|UTF16<LE|BE>)/OUTPUTCHARSETallows you to specify the codepage used by stdout when the output is redirected. (ACP|OEM|CP#|UTF8[SIG]|UTF16<LE|BE>[BOM])/PPOor/SAFEPPOwill only run the preprocessor and print the result to stdout. The safe version will not execute instructions like!appendfileor!system.!packhdrand!finalizeare never executed./WXtreats warnings as errors- Using the
/Dswitch one or more times will add to symbols to the globally defined list (See!define). - Using the
/Xswitch one or more times will execute the code you specify following it. Example: "/XAutoCloseWindow false" - Specifying a dash (
-) for the script name will tell makensis to use the standard input as a source.
/LICENSE:展示证书信息/V:输出信息设置0:不输出信息no output1:输出错误信息errors only2:输出警告和错误信息warnings and errors3:输出消息、警告和错误信息info, warnings, and errors4:全部输出all output
/P:编译进程级别0:idle1:below normal2:normal (default)3:above normal4:high5:realtime
/O:日志文件(将替代屏幕输出)/PAUSE:退出前暂停/NOCONFIG:禁止使用nsisconf.nsh文档。默认使用/CMDHELP:打印帮助信息/HDRINFO:打印option使用信息/NOCD:禁止将当前目录更改为.nsi文件的目录/INPUTCHARSET:允许您为没有BOM的文件指定特定的代码页/OUTPUTCHARSET:允许您指定重定向输出时stdout所使用的代码页/PPO或/SAFEPPO:只运行预处理器并将结果打印到标准输出。安全版本不会执行像!appendfile或!system这样的指令。!packhdr和!finalize永远不会执行/WX:警告被视为一种错误/D:一次或多次的使用。被添加到符号添中并被添加到到全局定义列表/X:一次或多次的使用。执行其后面的代码语句-:标准输入
3.1.2 Notes
- Parameters are processed in order.
makensis /Ddef script.nsiis not the same asmakensis script.nsi /Ddef. - If multiple scripts are specified, they are treated as one concatenated script.
参数按顺序处理。
makensis /Ddef script.nsi和makensis script.nsi /Ddef不一样。如果指定了多个脚本,则将它们视为一个连接的脚本。
3.1.3 Environment variables
makensis checks a number of environment variables that tell it where to locate the things it needs in order to create installers. These variables include:
NSISDIR,NSISCONFDIR- Places where nsis data and config files are installed.NSISDIRalters the script variable${NSISDIR}. See section 4.2.3 for more info.APPDATA(on Windows) orHOME(on other platforms) - Location of the per-user configuration file.
3.1.4 Examples
Basic usage:
makensis.exe myscript.nsi
Quiet mode:
makensis.exe /V1 myscript.nsi
Force compressor:
makensis.exe /X"SetCompressor /FINAL lzma" myscript.nsi
Change script behavior:
makensis.exe /DUSE_UPX /DVERSION=1.337 /DNO_IMAGES myscript.nsi
Parameters order:
makensis /XSection sectioncontents.nsi /XSectionEnd
3.2 Installer Usage
Generated installers and uninstallers accept a few options on the command line. These options give the user a bit more control over the installation process.
生成的安装程序和卸载程序接受命令行上的一些选项。这些选项让用户能够更好地控制安装过程。
3.2.1 Common Options
/NCRCdisables the CRC check, unless CRCCheck force was used in the script./Sruns the installer or uninstaller silently. See section 4.12 for more information./Dsets the default installation directory ($INSTDIR), overridingInstallDirandInstallDirRegKey. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. Only absolute paths are supported.
/NCRC将禁用CRC检查,除非脚本中使用了CRCCheck强制。/S以静默方式运行安装程序或卸载程序。更多信息请参见4.12节。/D设置默认安装目录($INSTDIR),覆盖InstallDir和InstallDirRegKey。它必须是命令行中使用的最后一个参数,并且不能包含任何引号,即使路径包含空格。仅支持绝对路径。
3.2.2 Uninstaller Specific Options
_?= sets $INSTDIR. It also stops the uninstaller from copying itself to the temporary directory and running from there. It can be used along withExecWaitto wait for the uninstaller to finish. It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces.
_?= sets $INSTDIR阻止卸载程序将自身复制到临时目录并从那里运行。它可以与ExecWait一起使用,以等待卸载完成。它必须是命令行中使用的最后一个参数,并且不能包含任何引号,即使路径包含空格。
3.2.3 Examples
installer.exe /NCRC
installer.exe /S
installer.exe /D=C:\Program Files\NSIS
installer.exe /NCRC /S /D=C:\Program Files\NSIS
uninstaller.exe /S _?=C:\Program Files\NSIS
# uninstall old version
ExecWait '"$INSTDIR\uninstaller.exe" /S _?=$INSTDIR'