\S1{miscinst} Miscellaneous Instructions

\S2{geterrorlevel} GetErrorLevel

\c user_var(error level output)

Returns the last error level set by \R{seterrorlevel}{SetErrorLevel} or -1 if it was never used.

\c GetErrorLevel $0
\c IntOp $0 $0 + 1
\c SetErrorLevel $0

\S2{getinstdirerror} GetInstDirError

\c user_var(error output)

Use in the leave function of a directory page. Reads the flag set if '\R{adirverify}{DirVerify leave}' is used. Possible values:

0: No error

1: Invalid installation directory

2: Not enough space on installation drive

\c !include LogicLib.nsh
\c PageEx directory
\c   DirVerify leave
\c   PageCallbacks "" "" dirLeave
\c PageExEnd
\c
\c Function dirLeave
\c   GetInstDirError $0
\c   ${Switch} $0
\c     ${Case} 0
\c       MessageBox MB_OK "valid installation directory"
\c       ${Break}
\c     ${Case} 1
\c       MessageBox MB_OK "invalid installation directory!"
\c       Abort
\c       ${Break}
\c     ${Case} 2
\c       MessageBox MB_OK "not enough free space!"
\c       Abort
\c       ${Break}
\c   ${EndSwitch}
\c FunctionEnd

\S2{initpluginsdir} InitPluginsDir

Initializes the plug-ins dir (\R{varconstant}{$PLUGINSDIR}) if not already initialized.

\c InitPluginsDir
\c File /oname=$PLUGINSDIR\image.bmp image.bmp

\S2{nop} Nop

Does nothing.

\S2{seterrorlevel} SetErrorLevel

\c error_level

Sets the error level of the installer or uninstaller to \e{error_level}. See \R{errorlevels}{Error Levels} for more information.

\c IfRebootFlag 0 +2
\c   SetErrorLevel 4

\S2{setregview} SetRegView

\c \\<b\\>32\\</b\\>|64|lastused

Sets the registry view affected by \R{registry}{registry commands}. On Windows x64 there are two views. One for 32-bit applications and one for x64 applications. By default, 32-bit applications running on x64 systems under WOW64 have access only to the 32-bit view. Using \c{SetRegView 64} allows the installer to access keys in the x64 view of the registry.

Affects \R{deleteregkey}{DeleteRegKey}, \R{deleteregvalue}{DeleteRegValue}, \R{enumregkey}{EnumRegKey}, \R{enumregvalue}{EnumRegValue}, \R{readregdword}{ReadRegDWORD}, \R{readregstr}{ReadRegStr}, \R{writeregbin}{WriteRegBin}, \R{writeregdword}{WriteRegDWORD}, \R{writeregstr}{WriteRegStr} and \R{writeregexpandstr}{WriteRegExpandStr}.

Does not affect \R{ainstalldirregkey}{InstallDirRegKey}. Instead, the registry can be read using \R{readregstr}{ReadRegStr} in \R{oninit}{.onInit}.

\c SetRegView 32
\c ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
\c DetailPrint $0 # prints C:\Program Files (x86)
\c SetRegView 64
\c ReadRegStr $0 HKLM Software\Microsoft\Windows\CurrentVersion ProgramFilesDir
\c DetailPrint $0 # prints C:\Program Files

\c Function .onInit
\c   SetRegView 64
\c   ReadRegStr $INSTDIR HKLM Software\NSIS ""
\c   SetRegView 32
\c FunctionEnd

\S2{setshellvarcontext} SetShellVarContext

\c \\<b\\>current\\</b\\>|all

Sets the context of $SMPROGRAMS and other shell folders. If set to 'current' (the default), the current user's shell folders are used. If set to 'all', the 'all users' shell folder is used. The all users folder may not be supported on all OSes. If the all users folder is not found, the current user folder will be used. Please take into consideration that a "normal user" has no rights to write in the all users area. Only admins have full access rights to the all users area. You can check this by using the UserInfo plug-in. See Contrib\\UserInfo\\UserInfo.nsi for an example.

Note that, if used in installer code, this will only affect the installer, and if used in uninstaller code, this will only affect the uninstaller. To affect both, it needs to be used in both.

\c SetShellVarContext current
\c StrCpy $0 $DESKTOP
\c SetShellVarContext all
\c StrCpy $1 $DESKTOP
\c MessageBox MB_OK $0$\n$1

\S2{sleep} Sleep

\c sleeptime_in_ms

Pauses execution in the installer for sleeptime_in_ms milliseconds. sleeptime_in_ms can be a variable, e.g. "$0" or a number, i.e. "666".

\c DetailPrint "sleeping..."
\c Sleep 3000
\c DetailPrint "back to work"
