Debian Codegraph @

Docs/src/var.but

raw
1 \H{variables} Variables
2
3 All variables are global and can be used in Sections or Functions. Note that by default, variables are limited to 1024 characters. To extend this limit, \R{build}{build NSIS} with a bigger value of the NSIS_MAX_STRLEN build setting or use the \W{https://nsis.sourceforge.io/download/specialbuilds/}{special build}.
4
5 \S1{varuser} User Variables
6
7 \e{$VARNAME}
8
9 User variables must be declared with the \R{var}{Var} command. You can use these variables to store values, work with string manipulation etc.
10
11 \S2{var} Var
12
13 \c [/GLOBAL] var_name
14
15 Declare a user variable. Allowed characters for variables names: [a-z][A-Z][0-9], '.' and '_'. All defined variables are global, even if defined in a section or a function. To make this clear, variables defined in a section or a function must use the /GLOBAL flag. The /GLOBAL flag is not required outside of sections and functions.
16
17 \c Var example
18 \c
19 \c Function testVar
20 \c Var /GLOBAL example2
21 \c
22 \c StrCpy $example "example value"
23 \c StrCpy $example2 "another example value"
24 \c FunctionEnd
25
26 \S1{varother} Other Writable Variables
27
28 \e{$0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $R0, $R1, $R2, $R3, $R4, $R5, $R6, $R7, $R8, $R9}
29
30 Registers. These variables can be used just like user variables, but are usually used in shared functions or macros. You don't have to declare these variables so you won't get any name conflicts when using them in shared code. When using these variables in shared code it's recommended that you use the stack to save and restore their original values. These variables can also be used for communication with plug-ins because they can be read and written by the plug-in DLLs.
31
32 \e{$INSTDIR}
33
34 The installation directory ($INSTDIR is modifiable using \R{StrCpy}{StrCpy}, \R{readregstr}{ReadRegStr}, \R{readinistr}{ReadINIStr}, etc. - This could be used, for example, in the \R{oninit}{.onInit} function to do a more advanced detection of install location).
35
36 Note that in uninstaller code, $INSTDIR contains the directory where the uninstaller lies. It does \s{not} necessarily contain the same value it contained in the installer. For example, if you write the uninstaller to $WINDIR and the user doesn't move it, $INSTDIR will be $WINDIR in the uninstaller. If you write the uninstaller to another location, you should keep the installer's $INSTDIR in the registry or an alternative storing facility and read it in the uninstaller.
37
38 \e{$OUTDIR}
39
40 The current output directory (set implicitly via \R{setoutpath}{SetOutPath} or explicitly via \R{StrCpy}{StrCpy}, \R{readregstr}{ReadRegStr}, \R{readinistr}{ReadINIStr}, etc)
41
42 \e{$CMDLINE}
43
44 The command line of the installer. The format of the command line can be one of the following:
45
46 \b "full\\path to\\installer.exe" PARAMETER PARAMETER PARAMETER
47
48 \b installer.exe PARAMETER PARAMETER PARAMETER
49
50 \b For parsing out the PARAMETER portion, see \R{getparameters}{GetParameters}. If /D= is specified on the command line (to override the install directory) it won't show up in $CMDLINE.
51
52 \e{$LANGUAGE}
53
54 The identifier of the language that is currently used. For example, English is 1033. You can only change this variable in \R{oninit}{.onInit}.
55
56 \S1{varconstant} Constants
57
58 Constants can also be used in the \R{ainstalldir}{InstallDir} attribute.
59
60 Note that some of the new constants will not work on every OS. For example, $CDBURN_AREA will only work on Windows XP and above. If it's used on Windows 98, it'll be empty. Unless mentioned otherwise, a constant should be available on every OS.
61
62 \e{$PROGRAMFILES}, \e{$PROGRAMFILES32}, \e{$PROGRAMFILES64}
63
64 The program files directory (usually \c{C:\\Program Files} but detected at runtime). On 64-bit Windows, $PROGRAMFILES and $PROGRAMFILES32 point to \c{C:\\Program Files (x86)} while $PROGRAMFILES64 points to \c{C:\\Program Files}. Use $PROGRAMFILES64 when installing 64-bit applications.
65
66 \e{$COMMONFILES}, \e{$COMMONFILES32}, \e{$COMMONFILES64}
67
68 The common files directory. This is a directory for components that are shared across applications (usually \c{C:\\Program Files\\Common Files} but detected at runtime). On 64-bit Windows, $COMMONFILES and $COMMONFILES32 point to \c{C:\\Program Files (x86)\\Common Files} while $COMMONFILES64 points to \c{C:\\Program Files\\Common Files}. Use $COMMONFILES64 when installing 64-bit applications.
69
70 \e{$DESKTOP}
71
72 The Windows desktop directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
73
74 \e{$EXEDIR}
75
76 The directory containing the installer executable (technically this is a variable and you can modify it, but it is probably not a good idea).
77
78 \e{$EXEFILE}
79
80 The base name of the installer executable.
81
82 \e{$EXEPATH}
83
84 The full path of the installer executable.
85
86 \e{$\{NSISDIR\}}
87
88 A symbol that contains the path where NSIS is installed. Useful if you want to reference resources that are in NSIS directory e.g. Icons, UIs etc.
89
90 When compiled with support for keeping makensis and the data in the same place (the default on Windows), it is in the same place as makensis, on other platforms it is set at compile time (See the INSTALL file for info). In both instances you can modify it at runtime by setting the NSISDIR environment variable. See \k{usageenvironment} for more info.
91
92 \e{$WINDIR}
93
94 The Windows directory (usually \c{C:\\Windows} or \c{C:\\WinNT} but detected at runtime).
95
96 \e{$SYSDIR}
97
98 The Windows system directory (usually \c{C:\\Windows\\System} or \c{C:\\WinNT\\System32} but detected at runtime).
99
100 \e{$TEMP}
101
102 The temporary directory.
103
104 \e{$STARTMENU}
105
106 The start menu folder (useful for adding start menu items using \R{createshortcut}{CreateShortcut}). The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
107
108 \e{$SMPROGRAMS}
109
110 The start menu programs folder (use this whenever you want $STARTMENU\\Programs). The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
111
112 \e{$SMSTARTUP}
113
114 The start menu programs / startup folder. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
115
116 \e{$QUICKLAUNCH}
117
118 The quick launch folder for IE4 active desktop and above. If quick launch is not available it simply returns the same as $TEMP.
119
120 \e{$DOCUMENTS}
121
122 The documents directory. A typical path for the current user is \c{C:\\Users\\Foo\\My Documents}. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
123
124 This constant is not available on Windows 95 unless Internet Explorer 4 is installed.
125
126 \e{$SENDTO}
127
128 The directory that contains Send To menu shortcut items.
129
130 \e{$RECENT}
131
132 The directory that contains shortcuts to the user's recently used documents.
133
134 \e{$FAVORITES}
135
136 The directory that contains shortcuts to the user's favorite websites, documents, etc. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
137
138 This constant is not available on Windows 95 unless Internet Explorer 4 is installed.
139
140 \e{$MUSIC}
141
142 The user's music files directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
143
144 This constant is available on Windows ME, XP and above.
145
146 \e{$PICTURES}
147
148 The user's picture files directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
149
150 This constant is available on Windows 2000, XP, ME and above.
151
152 \e{$VIDEOS}
153
154 The user's video files directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
155
156 This constant is available on Windows ME, XP and above.
157
158 \e{$NETHOOD}
159
160 The directory that contains link objects that may exist in the My Network Places/Network Neighborhood folder.
161
162 This constant is not available on Windows 95 unless Internet Explorer 4 with Active Desktop is installed.
163
164 \e{$FONTS}
165
166 The system's fonts directory.
167
168 \e{$TEMPLATES}
169
170 The document templates directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
171
172 \e{$APPDATA}
173
174 The (roaming) application data directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
175
176 Detection of the current user path requires Internet Explorer 4 and above. Detection of the all users path requires Internet Explorer 5 and above.
177
178 This constant is not available on Windows 95 unless Internet Explorer 4 with Active Desktop is installed.
179
180 \e{$LOCALAPPDATA}
181
182 The local (non-roaming) application data directory. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user. The All Users location is also known as \cw{%ProgramData%} on Vista and above.
183
184 This constant is available on Windows ME, 2000 and above.
185
186 \e{$PRINTHOOD}
187
188 The directory that contains link objects that may exist in the Printers folder.
189
190 This constant is not available on Windows 95 and Windows 98.
191
192 \e{$INTERNET_CACHE}
193
194 Internet Explorer's temporary internet files directory.
195
196 This constant is not available on Windows 95 nor Windows NT 4 unless Internet Explorer 4 with Active Desktop is installed.
197
198 \e{$COOKIES}
199
200 Internet Explorer's cookies directory.
201
202 This constant is not available on Windows 95 nor Windows NT 4 unless Internet Explorer 4 with Active Desktop is installed.
203
204 \e{$HISTORY}
205
206 Internet Explorer's history directory.
207
208 This constant is not available on Windows 95 nor Windows NT 4 unless Internet Explorer 4 with Active Desktop is installed.
209
210 \e{$PROFILE}
211
212 The user's profile directory. A typical path is \c{C:\\Users\\Foo}.
213
214 This constant is available on Windows 2000 and above.
215
216 \e{$ADMINTOOLS}
217
218 A directory where administrative tools are kept. The context of this constant (All Users or Current user) depends on the \R{setshellvarcontext}{SetShellVarContext} setting. The default is the current user.
219
220 This constant is available on Windows 2000, ME and above.
221
222 \e{$RESOURCES}
223
224 The resources directory that stores themes and other Windows resources (usually \c{$WINDIR\\Resources} but detected at runtime).
225
226 This constant is available on Windows XP and above.
227
228 \e{$RESOURCES_LOCALIZED}
229
230 The localized resources directory that stores themes and other Windows resources (usually \c{$WINDIR\\Resources\\1033} but detected at runtime).
231
232 This constant is available on Windows XP and above.
233
234 \e{$CDBURN_AREA}
235
236 A directory where files awaiting to be burned to CD are stored.
237
238 This constant is available on Windows XP and above.
239
240 \e{$HWNDPARENT}
241
242 HWND of the main window (in decimal).
243
244 \e{$PLUGINSDIR}
245
246 The path to a temporary folder created upon the first usage of a plug-in or a call to \R{initpluginsdir}{InitPluginsDir}. This folder is automatically deleted when the installer exits. This makes this folder the ideal folder to hold INI files for \L{../Docs/InstallOptions/Readme.html}{InstallOptions}, bitmaps for the splash plug-in, or any other file that a plug-in needs to work.
247
248 \e{$USER..} and \e{$COMMON..}
249
250 A handful of constants are available as aliases that are not affected by \R{setshellvarcontext}{SetShellVarContext}: \e{$USERTEMPLATES}, \e{$USERSTARTMENU}, \e{$USERSMPROGRAMS}, \e{$USERDESKTOP}, \e{$COMMONTEMPLATES}, \e{$COMMONSTARTMENU}, \e{$COMMONSMPROGRAMS}, \e{$COMMONDESKTOP} and \e{$COMMONPROGRAMDATA}.
251
252 \S1{varstrings} Constants Used in Strings
253
254 \e{$$}
255
256 Use to represent $.
257
258 \e{$\\r}
259
260 Use to represent a carriage return (\\r).
261
262 \e{$\\n}
263
264 Use to represent a newline (\\n).
265
266 \e{$\\t}
267
268 Use to represent a tab (\\t).