Debian Codegraph @

Docs/src/basic.but

raw
1 \H{instr} Instructions
2
3 \S1{basicinstructions} Basic Instructions
4
5 The instructions that NSIS uses for scripting are sort of a cross between PHP and assembly. There are no real high level language constructs but the instructions themselves are (for the most part) high level, and you have handy string capability (i.e. you don't have to worry about concatenating strings, etc). You essentially have 25 registers (20 general purpose, 5 special purpose), and a stack.
6
7 \S2{delete} Delete
8
9 \c [/REBOOTOK] file
10
11 Delete file (which can be a file or wildcard, but should be specified with a full path) on the target system. If /REBOOTOK is specified and the file cannot be deleted then the file is deleted when the system reboots -- if the file will be deleted on a reboot, the reboot flag will be set. The error flag is set if files are found and cannot be deleted. The error flag is not set when trying to delete a file that does not exist.
12
13 \c Delete $INSTDIR\somefile.dat
14
15 \NsisWarnBlockContainerBegin
16 \NsisBlockHeaderWarning The /REBOOTOK switch requires administrator rights on Windows NT and later.
17 \NsisWarnBlockContainerEnd
18
19 \S2{exec} Exec
20
21 \c command
22
23 Execute the specified program and continue immediately. Note that the file specified must exist on the target system, not the compiling system. $OUTDIR is used as the working directory. The error flag is set if the process could not be launched. Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: Exec '"$INSTDIR\\command.exe" parameters'. If you don't put it in quotes it will \e{not} work on Windows 9x with or without parameters.
24
25 \c Exec '"$INSTDIR\someprogram.exe"'
26 \c Exec '"$INSTDIR\someprogram.exe" some parameters'
27
28 \S2{execshell} ExecShell
29
30 \c [flags] action file [parameters] [SW_SHOWDEFAULT | SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED | SW_HIDE]
31
32 Execute the specified file using ShellExecuteEx. Note that \cw{action} is usually "open", "print", etc, but can be an empty string to use the default action. \cw{Parameters} and the show type are optional. $OUTDIR is used as the working directory. The error flag is set if the file could not be launched. \cw{Flags} can be any combination of /ALLOWERRORUI, /DOENVSUBST and /INVOKEIDLIST.
33
34 \c ExecShell "open" "http://nsis.sf.net/"
35 \c ExecShell "" "$SysDir\Notepad.exe" "" SW_SHOWMAXIMIZED
36 \c ExecShell "print" "$INSTDIR\readme.txt"
37 \c ExecShell /INVOKEIDLIST "properties" "$TEMP"
38
39 \S2{execshellwait} ExecShellWait
40
41 \c [flags] action file [parameters] [SW_SHOWDEFAULT | SW_SHOWNORMAL | SW_SHOWMAXIMIZED | SW_SHOWMINIMIZED | SW_HIDE]
42
43 Execute the specified file using ExecShell and wait for executed process to quit. It will only wait for executable files, not other file types nor URLs.
44
45 \S2{execwait} ExecWait
46
47 \c command [user_var(exit code)]
48
49 Execute the specified program and wait for the executed process to quit. See \R{exec}{Exec} for more information. If no output variable is specified \R{execwait}{ExecWait} sets the error flag if the program executed returns a nonzero error code, or if there is an error. If an output variable is specified, \R{execwait}{ExecWait} sets the variable with the exit code (and only sets the error flag if an error occurs; if an error occurs the contents of the user variable are undefined). Note, if the command could have spaces, you should put it in quotes to delimit it from parameters. e.g.: ExecWait '"$INSTDIR\\command.exe" parameters'. If you don't put it in quotes it will \e{not} work on Windows 9x with or without parameters.
50
51 \c ExecWait '"$INSTDIR\someprogram.exe"'
52 \c ExecWait '"$INSTDIR\someprogram.exe"' $0
53 \c DetailPrint "some program returned $0"
54
55 \S2{file} File
56
57 \c [/nonfatal] [/a] ([/r] [/x file|wildcard [...]] (file|wildcard) [...] | /oname=file.dat infile.dat)
58
59 Adds file(s) to be extracted to the current output path ($OUTDIR).
60
61 \b Note that the output file name is $OUTDIR\\filename_portion_of_file.
62
63 \b Use /oname=X switch to change the output name. X may contain variables and can be a fully qualified path or a relative path in which case it will be appended to $OUTDIR set by \R{setoutpath}{SetOutPath}. When using this switch, only one file can be specified. If the output name contains spaces, quote the entire parameter, including /oname, as shown in the examples below.
64
65 \b Wildcards are supported.
66
67 \b If the /r switch is used, matching files and directories are recursively searched for in subdirectories. If just one path segment is specified (e.g. \c{File /r something}), the current directory will be recursively searched. If more than one segment is specified (e.g. \c{File /r something\\*.*}), the last path segment will be used as the matching condition and anything before it specifies which directory to search recursively. If a directory name matches, all of its contents is added recursively. Directory structure is preserved.
68
69 \b Use the /x switch to exclude files and directories.
70
71 \b If the /a switch is used, the attributes of the file(s) added will be preserved.
72
73 \b The \R{file}{File} command sets the error flag if overwrite mode is set to 'try' and the file could not be overwritten, or if the overwrite mode is set to 'on' and the file could not be overwritten and the user selects ignore.
74
75 \b If the /nonfatal switch is used and no files are found, a warning will be issued instead of an error.
76
77 \c File something.exe
78 \c File /a something.exe
79 \c File *.exe
80 \c File /r *.dat
81 \c File /r data
82 \c File /oname=temp.dat somefile.ext
83 \c File /oname=$TEMP\temp.dat somefile.ext
84 \c File "/oname=$TEMP\name with spaces.dat" somefile.ext
85 \c File /nonfatal "a file that might not exist"
86 \c File /r /x CVS myproject\*.*
87 \c File /r /x *.res /x *.obj /x *.pch source\*.*
88
89 \s{Note:} When using the \e{/r} switch, both matching directories and files will be searched. This is always done with or without the use of wildcards, even if the given path perfectly matches one directory. That means, the following directory structure:
90
91 \c <DIR> something
92 \c file.dat
93 \c another.dat
94 \c <DIR> dir
95 \c something
96 \c <DIR> dir2
97 \c file2.dat
98 \c <DIR> another
99 \c <DIR> something
100 \c readme.txt
101
102 with the following \e{File} usage:
103
104 \c File /r something
105
106 will match the directory named \e{something} in the root directory, the file named \e{something} in the directory named \e{dir} and the directory named \e{something} in the directory named \e{another}. To match only the directory named \e{something} in the root directory, use the following:
107
108 \c File /r something\*.*
109
110 When adding \e{\\*.*}, it will be used as the matching condition and \e{something} will be used as the directory to search. When only \e{something} is specified, the current directory will be recursively searched for every file and directory named \e{something} and \e{another\\something} will be matched.
111
112 \S2{rename} Rename
113
114 \c [/REBOOTOK] source_file dest_file
115
116 Rename source_file to dest_file. You can use it to move a file from anywhere on the system to anywhere else and you can move a directory to somewhere else on the same drive. The destination file must not exist or the move will fail (unless you are using /REBOOTOK). If /REBOOTOK is specified, and the file cannot be moved (if, for example, the destination exists), then the file is moved when the system reboots. If the file will be moved on a reboot, the reboot flag will be set. The error flag is set if the file cannot be renamed (and /REBOOTOK is not used) or if the source file does not exist.
117
118 If no absolute path is specified the current folder will be used. The current folder is the folder set using the last \R{setoutpath}{SetOutPath} instruction. If you have not used \R{setoutpath}{SetOutPath} the current folder is \R{varother}{$EXEDIR}.
119
120 \c Rename $INSTDIR\file.ext $INSTDIR\file.dat
121
122 \NsisWarnBlockContainerBegin
123 \NsisBlockHeaderWarning The /REBOOTOK switch requires administrator rights on Windows NT and later.
124 \NsisWarnBlockContainerEnd
125
126 \NsisWarnBlockContainerBegin
127 \NsisBlockHeaderWarning Files cannot be moved from one drive to another if a reboot is required.
128 \NsisWarnBlockContainerEnd
129
130 \S2{reservefile} ReserveFile
131
132 \c [/nonfatal] [/r] [/x file|wildcard [...]] file [file...] | [/nonfatal] /plugin file.dll
133
134 Reserves a file in the data block for later use. Files are added to the compressed data block in the order they appear in the script. Functions, however, are not necessarily called in the order they appear in the script. Therefore, if you add a file in a function called early but put the function at the end of the script, all of the files added earlier will have to be decompressed to get to the required file. This process can take a long time if there a lot of files. \R{oninit}{.onInit} is one such function. It is called at the very beginning, before anything else appears. If you put it at the very end of the script, extract some files in it and have lots of files added before it, the installer might take a very long time to load. This is where this command comes useful, allowing you to speed up the loading process by including the file at the top of the data block instead of letting NSIS seek all the way down to the bottom of the \e{compressed} data block.
135
136 Use /plugin to reserve a plugin in $\{NSISDIR\}\\Plugins\\*.
137
138 See \R{file}{File} for more information about the parameters.
139
140 \S2{rmdir} RMDir
141
142 \c [/r] [/REBOOTOK] directory_name
143
144 Remove the specified directory (fully qualified path with no wildcards). Without /r, the directory will only be removed if it is completely empty. If /r is specified the directory will be removed recursively, so all directories and files in the specified directory will be removed. If /REBOOTOK is specified, any file or directory which could not be removed during the process will be removed on reboot -- if any file or directory will be removed on a reboot, the reboot flag will be set. The error flag is set if any file or directory cannot be removed.
145
146 \c RMDir $INSTDIR
147 \c RMDir $INSTDIR\data
148 \c RMDir /r /REBOOTOK $INSTDIR
149 \c RMDir /REBOOTOK $INSTDIR\DLLs
150
151 Note that the current working directory can not be deleted. The current working directory is set by \R{setoutpath}{SetOutPath}. For example, the following example will not delete the directory.
152
153 \c SetOutPath $TEMP\dir
154 \c RMDir $TEMP\dir
155
156 The next example will succeed in deleting the directory.
157
158 \c SetOutPath $TEMP\dir
159 \c SetOutPath $TEMP
160 \c RMDir $TEMP\dir
161
162 \NsisWarnBlockContainerBegin
163 \NsisBlockHeaderWarning Using \e{RMDir /r $INSTDIR} in the uninstaller is not safe. Though it is unlikely, the user might select to install to the root of the Program Files folder and this command would wipe out the entire Program Files folder, including all other installed programs! The user can also put other files in the installation folder and wouldn't expect them to get deleted along with the program. Solutions are \W{https://nsis.sourceforge.io/Uninstall_only_installed_files}{available} for easily uninstalling only files which were installed by the installer.
164 \NsisWarnBlockContainerEnd
165
166 \NsisWarnBlockContainerBegin
167 \NsisBlockHeaderWarning The /REBOOTOK switch requires administrator rights on Windows NT and later.
168 \NsisWarnBlockContainerEnd
169
170 \S2{setoutpath} SetOutPath
171
172 \c outpath
173
174 Sets the output path ($OUTDIR) and creates it (recursively if necessary), if it does not exist. Must be a full pathname, usually is just $INSTDIR (you can specify $INSTDIR with a single "-" if you are lazy).
175
176 \c SetOutPath $INSTDIR
177 \c File program.exe