脚本格式
Commands
命令行是这样的形式 'command [parameters]'
File "myfile"
Comments
以;或#开始的行被认为是注释行,你可以在命令行后放注释,也可以使用c风格的注释。
; Comment
# Comment
/*
Comment
Comment
*/
File "myfile" ; Comment
如果你需要以;或#作为参数,你应把他们放在引号里面。
Plug-ins
插件调用的方法:'plugin::command[parameters]'
nsExec::Exec "myfile"
Numbers
作为参数的数值,可以用整数、16进制(以0x开头)、8进制(以0开头)
颜色值用16位进制表示,但不要0x开头。
IntCmp 1 0x1
SetCtrlColors $HWND CCCCCC
Strings
若表示一个带有空格的字符串,应该使用引号
MessageBox MB_OK "Hi there!"
Quotes only have the property of containing a parameter if they begin the parameter.引号可以是单引号,双引号,或者后单引号(波浪号下面的)。
你可以用$/来表明该引号是参数的一部分
MessageBox MB_OK "I'll be happy"
MessageBox MB_OK 'And he said to me "Hi there"'
MessageBox MB_OK `And he said to me "I'll be fucked"`
MessageBox MB_OK "$/"A quote from a wise man$/" said the wise man"
在字符串中,$/r,$/n,$/t分别表示回车,换行,制表。
Variables
变量必须以$开头,变量必须先声明才可以使用,且大小写敏感。
Var MYVAR
StrCpy $MYVAR "myvalue"
Long commands
若命令行较长需要多行写,你应该使用反斜杠进行换行(类似c++)。
CreateShortCut "$SMPROGRAMES/NSIS/ZIP2EXE project workspace.lnk" /
$INSTDIR/source/zip2exe/zip2exe.dsw"
MessageBox MB_YESNO|MB_ICONQUESTION /
"Do you want to remove all files in the folder? /
(If you have anything you created that you want /
to keep, click No)" /
IDNO NoRemoveLabel
Configuration file
若"makensis.exe"的目录下有"nsisconf.nsh"这样的文件,则该文件会被默认包含在任何脚本文件中,除非/NOCONFIG编译开关被指定。