| 1 |
\S1{flowcontrol} Flow Control Instructions |
| 2 |
|
| 3 |
\S2{abort} Abort |
| 4 |
|
| 5 |
\c [user_message] |
| 6 |
|
| 7 |
Cancels the install, stops execution of script, and displays user_message in the status display. Note: you can use this from \R{callbacks}{Callback functions} to do special things. \R{pages}{Page callbacks} also uses \R{abort}{Abort} for special purposes. |
| 8 |
|
| 9 |
\c Abort |
| 10 |
\c Abort "can't install" |
| 11 |
|
| 12 |
\S2{call} Call |
| 13 |
|
| 14 |
\c function_name | :label_name | user_var(input) |
| 15 |
|
| 16 |
Calls the function named \e{function_name}, the label named \e{label_name}, or a variable that specifies an address. An address is returned by \R{getcurrentaddress}{GetCurrentAddress}, \R{getfunctionaddress}{GetFunctionAddress} or \R{getlabeladdress}{GetLabelAddress}. A call returns when it encounters a \R{return}{Return} instruction. Sections and functions are automatically ended with a \R{return}{Return} instruction. Uninstall functions cannot be called from installer functions and sections, and vice-versa. |
| 17 |
|
| 18 |
\c Function func |
| 19 |
\c Call :label |
| 20 |
\c DetailPrint "#1: This will only appear 1 time." |
| 21 |
\c label: |
| 22 |
\c DetailPrint "#2: This will appear before and after message #1." |
| 23 |
\c Call :.global_label |
| 24 |
\c FunctionEnd |
| 25 |
\c |
| 26 |
\c Section |
| 27 |
\c Call func |
| 28 |
\c Return |
| 29 |
\c |
| 30 |
\c .global_label: |
| 31 |
\c DetailPrint "#3: The global label was called" |
| 32 |
\c SectionEnd |
| 33 |
|
| 34 |
\S2{clearerrors} ClearErrors |
| 35 |
|
| 36 |
Clears the error flag. |
| 37 |
|
| 38 |
\c ClearErrors |
| 39 |
\c IfErrors 0 +2 |
| 40 |
\c MessageBox MB_OK "this message box will never show" |
| 41 |
|
| 42 |
\S2{getcurrentaddress} GetCurrentAddress |
| 43 |
|
| 44 |
\c user_var(output) |
| 45 |
|
| 46 |
Gets the address of the current instruction (the \R{getcurrentaddress}{GetCurrentAddress}) and stores it in the output user variable. This user variable then can be passed to \R{call}{Call} or \R{goto}{Goto}. |
| 47 |
|
| 48 |
\c Function func |
| 49 |
\c DetailPrint "function" |
| 50 |
\c IntOp $0 $0 + 2 ; Calculate the address after of the instruction after "Goto callFunc" in the Section |
| 51 |
\c Call $0 |
| 52 |
\c DetailPrint "function end" |
| 53 |
\c FunctionEnd |
| 54 |
\c |
| 55 |
\c Section |
| 56 |
\c DetailPrint "section" |
| 57 |
\c GetCurrentAddress $0 |
| 58 |
\c Goto callFunc |
| 59 |
\c |
| 60 |
\c DetailPrint "back in section" |
| 61 |
\c Return |
| 62 |
\c |
| 63 |
\c callFunc: |
| 64 |
\c Call func |
| 65 |
\c DetailPrint "section end" |
| 66 |
\c SectionEnd |
| 67 |
|
| 68 |
\S2{getfunctionaddress} GetFunctionAddress |
| 69 |
|
| 70 |
\c user_var(output) function_name |
| 71 |
|
| 72 |
Gets the address of the function and stores it in the output user variable. This user variable then can be passed to \R{call}{Call} or \R{goto}{Goto}. Note that if you \R{goto}{Goto} an address which is the output of \R{getfunctionaddress}{GetFunctionAddress}, your function will never be returned to (when the function you Goto'd to returns, you return instantly). |
| 73 |
|
| 74 |
\c Function func |
| 75 |
\c DetailPrint "function" |
| 76 |
\c FunctionEnd |
| 77 |
\c |
| 78 |
\c Section |
| 79 |
\c GetFunctionAddress $0 func |
| 80 |
\c Call $0 |
| 81 |
\c SectionEnd |
| 82 |
|
| 83 |
\S2{getlabeladdress} GetLabelAddress |
| 84 |
|
| 85 |
\c user_var(output) label |
| 86 |
|
| 87 |
Gets the address of the label and stores it in the output user variable. This user variable then can be passed to \R{call}{Call} or \R{goto}{Goto}. Note that you may only call this with labels accessible from your function, but you can call it from anywhere (which is potentially dangerous). Note that if you \R{call}{Call} the output of \R{getlabeladdress}{GetLabelAddress}, code will be executed until it Return's (explicitly or implicitly at the end of a function), and then you will be returned to the statement after the \R{call}{Call}. |
| 88 |
|
| 89 |
\c label: |
| 90 |
\c DetailPrint "label" |
| 91 |
\c GetLabelAddress $0 label |
| 92 |
\c IntOp $0 $0 + 4 |
| 93 |
\c Goto $0 |
| 94 |
\c DetailPrint "done" |
| 95 |
|
| 96 |
\S2{goto} Goto |
| 97 |
|
| 98 |
\c label_to_jump_to | +offset| -offset| user_var(target) |
| 99 |
|
| 100 |
If label is specified, goto the label 'label_to_jump_to:'. |
| 101 |
|
| 102 |
If +offset or -offset is specified, jump is relative by offset instructions. Goto +1 goes to the next instruction, Goto -1 goes to the previous instruction, etc. |
| 103 |
|
| 104 |
If a user variable is specified, jumps to absolute address (generally you will want to get this value from a function like \R{getlabeladdress}{GetLabelAddress}). Compiler flag commands and \R{ssectionin}{SectionIn} aren't instructions so jumping over them has no effect. |
| 105 |
|
| 106 |
\c Goto label |
| 107 |
\c Goto +2 |
| 108 |
\c Goto -2 |
| 109 |
\c Goto $0 |
| 110 |
|
| 111 |
\S2{ifabort} IfAbort |
| 112 |
|
| 113 |
\c label_to_goto_if_abort [label_to_goto_if_no_abort] |
| 114 |
|
| 115 |
Will "return" true if the installation has been aborted. This can happen if the user chose abort on a file that failed to create (or overwrite) or if the user aborted by hand. This function can only be called from the leave function of the instfiles \R{page}{page}. |
| 116 |
|
| 117 |
\c Page instfiles "" "" instfilesLeave |
| 118 |
\c |
| 119 |
\c Function instfilesLeave |
| 120 |
\c IfAbort 0 +2 |
| 121 |
\c MessageBox MB_OK "user aborted" |
| 122 |
\c FunctionEnd |
| 123 |
|
| 124 |
\S2{iferrors} IfErrors |
| 125 |
|
| 126 |
\c jumpto_iferror [jumpto_ifnoerror] |
| 127 |
|
| 128 |
Checks and clears the error flag, and if it is set, it will goto jumpto_iferror, otherwise it will goto jumpto_ifnoerror. The error flag is set by other instructions when a recoverable error (such as trying to delete a file that is in use) occurs. |
| 129 |
|
| 130 |
\c ClearErrors |
| 131 |
\c File file.dat |
| 132 |
\c IfErrors 0 +2 |
| 133 |
\c Call ErrorHandler |
| 134 |
|
| 135 |
\S2{iffileexists} IfFileExists |
| 136 |
|
| 137 |
\c file_to_check_for jump_if_present [jump_otherwise] |
| 138 |
|
| 139 |
Checks for existence of file(s) file_to_check_for (which can be a wildcard, or a directory), and Gotos jump_if_present if the file exists, otherwise Gotos jump_otherwise. If you want to check to see if a file is a directory, use \R{iffileexists}{IfFileExists} DIRECTORY\\*.* |
| 140 |
|
| 141 |
\c IfFileExists $WINDIR\notepad.exe 0 +2 |
| 142 |
\c MessageBox MB_OK "notepad is installed" |
| 143 |
|
| 144 |
\S2{ifrebootflag} IfRebootFlag |
| 145 |
|
| 146 |
\c jump_if_set [jump_if_not_set] |
| 147 |
|
| 148 |
Checks the reboot flag, and jumps to jump_if_set if the reboot flag is set, otherwise jumps to jump_if_not_set. The reboot flag can be set by \R{delete}{Delete} and \R{rename}{Rename}, or manually with \R{setrebootflag}{SetRebootFlag}. |
| 149 |
|
| 150 |
\c IfRebootFlag 0 noreboot |
| 151 |
\c MessageBox MB_YESNO "A reboot is required to finish the installation. Do you wish to reboot now?" IDNO noreboot |
| 152 |
\c Reboot |
| 153 |
\c noreboot: |
| 154 |
|
| 155 |
\S2{ifsilent} IfSilent |
| 156 |
|
| 157 |
\c jump_if_silent [jump_if_not] |
| 158 |
|
| 159 |
Checks the silent flag, and jumps to jump_if_silent if the installer is silent, otherwise jumps to jump_if_not. The silent flag can be set by \R{asilentinstall}{SilentInstall}, \R{asilentuninstall}{SilentUninstall}, \R{setsilent}{SetSilent} and by the user passing /S on the command line. |
| 160 |
|
| 161 |
\c IfSilent +2 |
| 162 |
\c ExecWait '"$INSTDIR\nonsilentprogram.exe"' |
| 163 |
|
| 164 |
\S2{ifshellvarcontextall} IfShellVarContextAll |
| 165 |
|
| 166 |
\c jump_if_true [jump_if_false] |
| 167 |
|
| 168 |
Checks if \R{setshellvarcontext}{SetShellVarContext} is set to \e{all}. |
| 169 |
|
| 170 |
\S2{ifrtllanguage} IfRtlLanguage |
| 171 |
|
| 172 |
\c jump_if_true [jump_if_false] |
| 173 |
|
| 174 |
Checks if active language is a RTL language. |
| 175 |
|
| 176 |
\NsisWarnBlockContainerBegin |
| 177 |
\NsisBlockHeaderWarning Do not call this in [un].onInit because the language file has not been fully initialized. |
| 178 |
\NsisWarnBlockContainerEnd |
| 179 |
|
| 180 |
\S2{intcmp} IntCmp |
| 181 |
|
| 182 |
\c val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more] |
| 183 |
|
| 184 |
Compares two integers val1 and val2. If val1 and val2 are equal, Gotos jump_if_equal, otherwise if val1 < val2, Gotos jump_if_val1_less, otherwise if val1 > val2, Gotos jump_if_val1_more. |
| 185 |
|
| 186 |
\c IntCmp $0 5 is5 lessthan5 morethan5 |
| 187 |
\c is5: |
| 188 |
\c DetailPrint "$$0 == 5" |
| 189 |
\c Goto done |
| 190 |
\c lessthan5: |
| 191 |
\c DetailPrint "$$0 < 5" |
| 192 |
\c Goto done |
| 193 |
\c morethan5: |
| 194 |
\c DetailPrint "$$0 > 5" |
| 195 |
\c Goto done |
| 196 |
\c done: |
| 197 |
|
| 198 |
\S2{intcmpu} IntCmpU |
| 199 |
|
| 200 |
\c val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more] |
| 201 |
|
| 202 |
Same as \R{intcmp}{IntCmp}, but treats the values as unsigned integers. |
| 203 |
|
| 204 |
\S2{int64cmp} Int64Cmp |
| 205 |
|
| 206 |
\c val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more] |
| 207 |
|
| 208 |
Same as \R{intcmp}{IntCmp}, but treats the values as 64-bit integers. |
| 209 |
|
| 210 |
\NsisFuncReq64 |
| 211 |
|
| 212 |
\S2{int64cmpu} Int64CmpU |
| 213 |
|
| 214 |
\c val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more] |
| 215 |
|
| 216 |
Same as \R{intcmp}{IntCmp}, but treats the values as 64-bit unsigned integers. |
| 217 |
|
| 218 |
\NsisFuncReq64 |
| 219 |
|
| 220 |
\S2{intptrcmp} IntPtrCmp |
| 221 |
|
| 222 |
\c val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more] |
| 223 |
|
| 224 |
Same as \R{intcmp}{IntCmp}, but treats the values as pointer sized integers. |
| 225 |
|
| 226 |
\S2{intptrcmpu} IntPtrCmpU |
| 227 |
|
| 228 |
\c val1 val2 jump_if_equal [jump_if_val1_less] [jump_if_val1_more] |
| 229 |
|
| 230 |
Same as \R{intcmp}{IntCmp}, but treats the values as pointer sized unsigned integers. |
| 231 |
|
| 232 |
\S2{messagebox} MessageBox |
| 233 |
|
| 234 |
\c mb_option_list messagebox_text [/SD return] [return_check jumpto [return_check_2 jumpto_2]] |
| 235 |
|
| 236 |
Displays a \R{messagebox}{MessageBox} containing the text "messagebox_text". mb_option_list must be one or more of the following, delimited by |s (e.g. MB_YESNO|MB_ICONSTOP). |
| 237 |
|
| 238 |
\b \e{MB_OK} - Display with an OK button |
| 239 |
|
| 240 |
\b \e{MB_OKCANCEL} - Display with an OK and a cancel button |
| 241 |
|
| 242 |
\b \e{MB_ABORTRETRYIGNORE} - Display with abort, retry, ignore buttons |
| 243 |
|
| 244 |
\b \e{MB_RETRYCANCEL} - Display with retry and cancel buttons |
| 245 |
|
| 246 |
\b \e{MB_YESNO} - Display with yes and no buttons |
| 247 |
|
| 248 |
\b \e{MB_YESNOCANCEL} - Display with yes, no, cancel buttons |
| 249 |
|
| 250 |
\b \e{MB_ICONEXCLAMATION} - Display with exclamation icon |
| 251 |
|
| 252 |
\b \e{MB_ICONINFORMATION} - Display with information icon |
| 253 |
|
| 254 |
\b \e{MB_ICONQUESTION} - Display with question mark icon |
| 255 |
|
| 256 |
\b \e{MB_ICONSTOP} - Display with stop icon |
| 257 |
|
| 258 |
\b \e{MB_USERICON} - Display with installer's icon |
| 259 |
|
| 260 |
\b \e{MB_TOPMOST} - Make messagebox topmost |
| 261 |
|
| 262 |
\b \e{MB_SETFOREGROUND} - Set foreground |
| 263 |
|
| 264 |
\b \e{MB_RIGHT} - Right align text |
| 265 |
|
| 266 |
\b \e{MB_RTLREADING} - RTL reading order |
| 267 |
|
| 268 |
\b \e{MB_DEFBUTTON1} - Button 1 is default |
| 269 |
|
| 270 |
\b \e{MB_DEFBUTTON2} - Button 2 is default |
| 271 |
|
| 272 |
\b \e{MB_DEFBUTTON3} - Button 3 is default |
| 273 |
|
| 274 |
\b \e{MB_DEFBUTTON4} - Button 4 is default |
| 275 |
|
| 276 |
Return_check can be 0 (or empty, or left off), or one of the following: |
| 277 |
|
| 278 |
\b \e{IDABORT} - Abort button |
| 279 |
|
| 280 |
\b \e{IDCANCEL} - Cancel button |
| 281 |
|
| 282 |
\b \e{IDIGNORE} - Ignore button |
| 283 |
|
| 284 |
\b \e{IDNO} - No button |
| 285 |
|
| 286 |
\b \e{IDOK} - OK button |
| 287 |
|
| 288 |
\b \e{IDRETRY} - Retry button |
| 289 |
|
| 290 |
\b \e{IDYES} - Yes button |
| 291 |
|
| 292 |
If the return value of the \R{messagebox}{MessageBox} is return_check, the installer will Goto jumpto. |
| 293 |
|
| 294 |
Use the /SD parameter with one of the return_check values above to specify the option that will be used when the installer is silent. See \k{silent} for more information. |
| 295 |
|
| 296 |
\c MessageBox MB_OK "simple message box" |
| 297 |
\c MessageBox MB_YESNO "is it true?" IDYES true IDNO false |
| 298 |
\c true: |
| 299 |
\c DetailPrint "it's true!" |
| 300 |
\c Goto next |
| 301 |
\c false: |
| 302 |
\c DetailPrint "it's false" |
| 303 |
\c next: |
| 304 |
\c MessageBox MB_YESNO "is it true? (defaults to yes on silent installations)" /SD IDYES IDNO false2 |
| 305 |
\c DetailPrint "it's true (or silent)!" |
| 306 |
\c Goto next2 |
| 307 |
\c false2: |
| 308 |
\c DetailPrint "it's false" |
| 309 |
\c next2: |
| 310 |
|
| 311 |
\S2{return} Return |
| 312 |
|
| 313 |
Returns from a function or section. |
| 314 |
|
| 315 |
\c Function func |
| 316 |
\c StrCmp $0 "return now" 0 +2 |
| 317 |
\c Return |
| 318 |
\c # do stuff |
| 319 |
\c FunctionEnd |
| 320 |
\c |
| 321 |
\c Section |
| 322 |
\c Call func |
| 323 |
\c ;"Return" will return here |
| 324 |
\c SectionEnd |
| 325 |
|
| 326 |
\S2{quit} Quit |
| 327 |
|
| 328 |
Causes the installer to exit as soon as possible. After \R{quit}{Quit} is called, the installer will exit (no callback functions will get a chance to run). |
| 329 |
|
| 330 |
\S2{seterrors} SetErrors |
| 331 |
|
| 332 |
Sets the error flag. |
| 333 |
|
| 334 |
\c SetErrors |
| 335 |
\c IfErrors 0 +2 |
| 336 |
\c MessageBox MB_OK "this message box will always show" |
| 337 |
|
| 338 |
\S2{strcmp} StrCmp |
| 339 |
|
| 340 |
\c str1 str2 jump_if_equal [jump_if_not_equal] |
| 341 |
|
| 342 |
Compares (case insensitively) str1 to str2. If str1 and str2 are equal, Gotos jump_if_equal, otherwise Gotos jump_if_not_equal. |
| 343 |
|
| 344 |
\c StrCmp $0 "a string" 0 +3 |
| 345 |
\c DetailPrint '$$0 == "a string"' |
| 346 |
\c Goto +2 |
| 347 |
\c DetailPrint '$$0 != "a string"' |
| 348 |
|
| 349 |
\S2{strcmps} StrCmpS |
| 350 |
|
| 351 |
\c str1 str2 jump_if_equal [jump_if_not_equal] |
| 352 |
|
| 353 |
Same as \R{strcmp}{StrCmp}, but case sensitive. |