$sysval function
$sysval(index[,param[,param2]])
The $sysval function returns one of a number of predefined system-specific data items, for example the current screen resolution or available memory size. If index refers to a non-existing data item, the result is an empty string. The meaning and use of the optional param depends on the data item in question.
Note: In most cases, the same information is available through one of the predefined system information variables. If available, we strongly recommend that you use the predefined variables instead of the $sysval function for greater cross-platform robustness and error checking.
Parameters
All parameters may contain symbolic references; these are resolved before the function is applied. See Examples below.
- index
- Index of the desired data item; see below for a full list of currently defined indices.
- param
- Optional item-specific parameter; see the description of data item indices in the table below.
- param2
- Optional item-specific second parameter; see the description of data item indices in the table below.
Available data item indices
| Index | Data item | Example value | Preferred symbol | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Windows major version number | 6 | n/a | ||||||||||||||||||||||||||||
| 1 | Windows minor version number | 1 | n/a | ||||||||||||||||||||||||||||
| 2 | Windows build number | 7601 | WindowsBuild | ||||||||||||||||||||||||||||
| 3 | Windows major service pack level | 1 | ServicePackLevel | ||||||||||||||||||||||||||||
| 4 | Windows minor service pack level | 0 | ServicePackLevelMinor | ||||||||||||||||||||||||||||
| 5 | Windows platform ID: 1=Windows 9x, 2=Windows NT, other values are reserved | 2 | Version9x, VersionNT | ||||||||||||||||||||||||||||
| 6 | Windows CSD string (typically the service pack level) | Service Pack 1 | n/a | ||||||||||||||||||||||||||||
| 7 | Windows product type as per OSVERSIONEX.wProductType:
|
1 | MsiNTProductType | ||||||||||||||||||||||||||||
| 8 | Windows type; see the WindowsType documentation for possible values | 48 | WindowsType | ||||||||||||||||||||||||||||
| 9 | Windows Core flag: 0=Full installation, 1=Core installation | 0 | WindowsCore | ||||||||||||||||||||||||||||
| 10 | Windows version number as (major * 100) + minor | 601 | Version9x VersionNT VersionNT32 VersionNT64 |
||||||||||||||||||||||||||||
| 11 | Processor architecture as a decimal value:
|
9 | Arm64 Intel Intel64 MsiAMD64, MsiX64 |
||||||||||||||||||||||||||||
| 12 | Processor level; values depend on the processor architecture. Note that this level may reflect the emulated processor for non-native processes; it should not be relied upon for installation decisions. | 6 | n/a | ||||||||||||||||||||||||||||
| 13 | Windows 64-bit flag:
|
2 | VersionNT32 VersionNT64 |
||||||||||||||||||||||||||||
| 14 | Amount of physical memory, in MB | 8192 | PhysicalMemory | ||||||||||||||||||||||||||||
| 15 | Amount of virtual memory, in MB | 16384 | VirtualMemory | ||||||||||||||||||||||||||||
| 16 | Display color depth, in bits/pixel | 32 | ColorBits | ||||||||||||||||||||||||||||
| 17 | Display width, in pixels | 1680 | ScreenX | ||||||||||||||||||||||||||||
| 18 | Display height, in pixels | 1050 | ScreenY | ||||||||||||||||||||||||||||
| 19 | Display horizontal logical resolution, in pixels/logical inch | 96 | ScreenLPX | ||||||||||||||||||||||||||||
| 20 | Display vertical logical resolution, in pixels/logical inch | 96 | ScreenLPY | ||||||||||||||||||||||||||||
| 21 | Returns the Win32 API GetSystemMetrics() value of the metric given by the param parameter. See the Microsoft documentation for GetSystemMetrics() for a full list of available param indices. | 1680 | n/a | ||||||||||||||||||||||||||||
| 22 | Windows product suite mask as per OSVERSIONEX.wSuiteMask, formatted as a decimal number. This value can be used in combination with the optional param parameter as a bitwise AND mask to test for various product suite options, as follows (a nonzero masked result indicates the presence of that product suite):
|
256 | MsiNTSuiteBackOffice MsiNTSuiteDataCenter MsiNTSuiteEnterprise MsiNTSuitePersonal MsiNTSuiteSmallBusiness MsiNTSuiteSmallBusinessRestricted MsiNTSuiteWebServer TerminalServer |
||||||||||||||||||||||||||||
| 23 | Terminal Server flag: 0=not running under TS, nonzero=running under TS | 0 | n/a | ||||||||||||||||||||||||||||
| 24 | Elevation status of the installer's process: 0=not elevated, nonzero=elevated | 1 | AdminUser Privileged |
||||||||||||||||||||||||||||
| 25 | Current system date or time in UTC, formatted according to param in the following table. If param is omitted, format #0 is used.
|
#0: 20120518 #1: 2012-05-18 #2: 18/05/2012 #3: 18 May 2012 #4: 194324 #5: 19:43:24 #6: 7:43pm |
n/a | ||||||||||||||||||||||||||||
| 26 | Current system date or time in local time zone, formatted according to param using the same format indices as #25. | See #25 | Date, InstallDate, InstallTime, Time |
||||||||||||||||||||||||||||
| 27 | System language ID as per Windows conventions (decimal) | 1033 | SystemLanguageID | ||||||||||||||||||||||||||||
| 28 | User's language ID as per Windows conventions (decimal) | 3081 | UserLanguageID | ||||||||||||||||||||||||||||
| 29 | Current user's security identifier (SID) | S-1-5-21-53827593-7483943-5373609-1004 | UserSID | ||||||||||||||||||||||||||||
| 30 | Current user's login name | Dave | LogonUser | ||||||||||||||||||||||||||||
| 31 | Current user's login domain | D | n/a | ||||||||||||||||||||||||||||
| 32 | Process identifier of the installer's process | 1132 | TsuPID | ||||||||||||||||||||||||||||
| 33 | Generates a new GUID on each call, formatted as per standard GUID v4 conventions | {3E5944E4-0187-4941-8106-0E66B4FEFC91} | InstallID | ||||||||||||||||||||||||||||
| 34 | Generates a new 32-bit pseudo-random number on each call, formatted as 8 hexadecimal digits | 1369AAF6 | SessionID | ||||||||||||||||||||||||||||
| 35 |
Installed Microsoft Office version information according to param in the following table. If param is omitted, 0 is used.
|
#0: 15 (2013) #1: 64 (64-bit) #2: C:\Program Files\Microsoft Ofice\Office15 |
n/a | ||||||||||||||||||||||||||||
| 36 37 38 |
A group of functions that retrieve the installed .Net version number as a.b.c.d for a given major version (param) and CPU architecture (param2). This only works for .Net versions 5.x and later; for earlier .Net versions, use the VersionCLR variable. If the given <index, major, cpu> combination is not present on the system, the function returns 0.0.0.0 The result of the function can be used in conditional expressions, where it will be recognised as a version number and be compared accordingly. Note: this function is required because multiple .Net 5 and later versions can be installed in parallel on a given system, which means that a system may contain, for example, both .Net 8.0.20 and .Net 10.0.4.
|
10.0.12.0 | .Net version variables VersionCLR |
Examples
Here are some usage examples for this function:
- <$sysval(21, 0)>
- Returns the screen width of the primary monitor, in pixels, as per GetSystemMetrics(SM_CXSCREEN) call.
- <$sysval(21, 89)>
- Returns the nonzero Windows Server 2003 R2 build number if the installer is running on such a system, or zero if not.
- <$sysval(22, 0x200)>
- Returns the nonzero value 512 (i.e., True) if Windows XP Home Edition, Windows Vista Home Basic, or Windows Vista Home Premium is installed, and zero (i.e., False) otherwise.
- <$sysval(25)>
- Returns the current system date in the UTC time zone, formatted as YYYYMMDD.
- <$sysval(25,0)>
- Same as previous example, using explicit format #0
- <$sysval(26,6)>
- Returns the current system time in the local time zone, formatted according to the current user's regional conventions.
- <$sysval(34)>
- Returns an 8-digit (hexadecimal) pseudo-random number.
- <$sysval(37)>
- Returns the highest installed .Net Core x86 version, if any, or 0.0.0.0 if not installed. The first parameter is the function index 37, meaning .Net Core, while the second and third parameters are omitted and default to 0.
- <$sysval(37, 10, 1)>
- Returns the installed .Net Core 10.x x64 version, if any, or 0.0.0.0 if not installed. The first parameter is the function index 37, meaning .Net Core, the second parameter specifies the major .Net version 10, and the final parameter requests the x64 architecture.