$sysval function

$sysval(index [,param])

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.

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=Workstation, 2=Domain controller, 3=Server 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: 0=IA32, 6=IA64, 9=x64 (AMD or Intel), other values are reserved 9 n/a
12 Processor level; values depend on the processor architecture 6 Intel, Intel64,
MsiAMD64, MsiX64
13 Windows 64-bit flag: 0=32-bit system, 1=64-bit system (IA64), 2=64-bit system (x64) 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):
Param Product suite
0x0001 Small Business Server installed
0x0002 Advanced/Enterprise Server installed
0x0004 BackOffice installed
0x0010 Terminal Services installed
0x0020 Small Business Server with restricted license installed
0x0040 Windows XP Embedded installed
0x0080 Datacenter Server installed
0x0100 Single-session Remote Desktop installed
0x0200 Windows Home Edition installed
0x0400 Web Edition server installed
0x2000 Storage Server installed
0x4000 Compute Cluster installed
0x8000 Windows Home Server installed
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.
Param Format
0 Date as YYYYMMDD (internal format)
1 Date as YYYY-MM-DD (ISO 8601)
2 Date according to regional conventions, short format
3 Date according to regional conventions, long format
4 Time as HHMMSS (internal format)
5 Time as HH:MM:SS (ISO 8601)
6 Time according to regional conventions
#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 conventions {E04B148E-C63E-5A16-
228C-E34F9923FC87}
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.

Param Format
0 Internal major version number (12, 14, 15, etc. instead of 2007, 2010, 2013, etc.; empty if not found)
1 Bitness of the installation (32 or 64; empty if not found)
2 Installation path, or empty if not found
#0: 15 (2013)
#1: 64 (64-bit)
#2: C:\Program Files\Microsoft Ofice\Office15
n/a

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.

See also

Predefined system information variables