Export (0) Print
Expand All

Retrieving the Properties of the Operating System

Microsoft® Windows® 2000 Scripting Guide

Retrieving the Properties of the Operating System

Even though the operating systems on two different computers might have the same name and version number, those two operating systems can still differ. They might be configured with different language settings, support different encryption levels, or have different client licensing requirements.

Many differences between similar computers are reflected in the detailed property settings of their operating systems. These property settings can greatly affect the way each computer should be managed. For example, you might send a different technician to work on a computer running a Japanese version of a Windows 2000 operating system than you would send to work on a computer running a French version.

The WMI Win32_OperatingSystem class can be used to retrieve details of the operating system installed on a computer.

Important

  • Unfortunately, WMI can retrieve information only about the operating system currently being used by a computer. For example, suppose you have a dual-boot computer with Windows XP and Windows 2000 installed, and the computer is currently running under Windows XP. If you run a script to return information about the operating system, only information for Windows XP will be returned.

Some of the more commonly used properties from this class are listed in Table 8.9.

Table 8.9 Win32_OperatingSystem Properties

Property

Description

BootDevice

Name of the disk drive from which the Win32 operating system boots.

BuildNumber

Build number of the operating system. The build number can be used for more precise versioning information than product release version numbers.

For example, 2195 is the build number for the released version of Windows 2000.

BuildType

Type of build used for the operating system. The two primary build types are retail (the build purchased through a software vendor), and checked (test versions of the operating system that include special code to aid in debugging).

Caption

Name of the operating system.

CodeSet

Code page value used by the operating system.

A code page contains a character table used by the operating system to translate strings for different languages. The American National Standards Institute (ANSI) lists values that represent defined code pages. If the operating system does not use an ANSI code page, this member will be set to 0. The CodeSet string can use up to six characters to define the code page value. For example, the code page value for US English is 1252.

CountryCode

Code for the country/region used by the operating system.

Values are based on international phone dialing prefixes (also referred to as IBM country/region codes). The property can use up to six characters to define the country/region code value. For example, the country code for the United States is 1.

Debug

Operating system is a checked (debugged) build.

Checked builds provide error checking, argument verification, and system debugging code. Additional code in a checked binary generates a kernel debugger error message and breaks into the debugger. This helps to immediately determine the cause and location of the error. Performance suffers in the checked build because of the additional code that must be executed. In general, checked builds should be used on test computers, not production computers.

InstallDate

Date the operating system was installed, in UTC format.

NumberOfLicensedUsers

Number of user licenses for the operating system. If unlimited, this is returned as 0. If unknown, this is usually returned as -1.

Organization

Company name of the registered user of the operating system.

OSLanguage

Language version of the operating system installed. Sample values for this property include:

0001 - Arabic

0004 - Chinese

0009 - English

0401 - Arabic (Saudi Arabia)

0402 - Bulgarian

0403 - Catalan

0404 - Chinese (Taiwan)

0405 - Czech

0406 - Danish

0407 - German (Germany)

0408 - Greek

0409 - English (United States)

OSProductSuite

Installed and licensed system product additions to the operating system. Values include the following:

1 - Small Business Server

2 - Enterprise Server

4 - Back Office Server

8 - Communication Server

16 - Terminal Server

32 - Small Business Server (restricted)

64 - Embedded NT

128 - Data Center

OSType

Type of operating system. The most common values include:

16 = WIN95

17 = WIN98

18 = WINNT

19 = WINCE

The value 18 (WINNT) is returned as the OsType for Windows 2000 and Windows XP.

Primary

Boolean value that indicates whether this is the primary operating system. This property is meaningful only on multiple-boot computers that have more than one operating system installed.

RegisteredUser

Name of the registered user of the operating system.

SerialNumber

Serial identification number of the operating system.

Version

Version number of the operating system (for example, 4.0).

Scripting Steps

Listing 8.7 contains a script that retrieves the properties of the operating system currently in use on a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.

  2. Use a GetObject call to connect to the WMI namespace root\cimv2, and set the impersonation level to "impersonate."

  3. Use the ExecQuery method to query the Win32_OperatingSystem class.

    This query returns a collection consisting of the operating system currently in use on the computer.

  4. For the only operating system in the collection, echo the values for the specified properties.

Listing 8.7 Retrieving the Properties of the Operating System

  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
 Wscript.Echo "Boot Device: " & objOperatingSystem.BootDevice
 Wscript.Echo "Build Number: " & objOperatingSystem.BuildNumber
 Wscript.Echo "Build Type: " & objOperatingSystem.BuildType
 Wscript.Echo "Caption: " & objOperatingSystem.Caption
 Wscript.Echo "Code Set: " & objOperatingSystem.CodeSet
 Wscript.Echo "Country Code: " & objOperatingSystem.CountryCode
 Wscript.Echo "Debug: " & objOperatingSystem.Debug
 Wscript.Echo "Install Date: " & objOperatingSystem.InstallDate
 Wscript.Echo "Licensed Users: " & _
 objOperatingSystem.NumberOfLicensedUsers
 Wscript.Echo "Organization: " & objOperatingSystem.Organization
 Wscript.Echo "OS Language: " & objOperatingSystem.OSLanguage
 Wscript.Echo "OS Product Suite: " & objOperatingSystem.OSProductSuite
 Wscript.Echo "OS Type: " & objOperatingSystem.OSType
 Wscript.Echo "Primary: " & objOperatingSystem.Primary
 Wscript.Echo "Registered User: " & objOperatingSystem.RegisteredUser
 Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber
 Wscript.Echo "Version: " & objOperatingSystem.Version
Next

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft