Identifying the Chassis Type of a Computer

Microsoft® Windows® 2000 Scripting Guide

The chassis is the physical container that houses the components of a computer. Chassis types include the tower configuration, desktop computer, notebook computer, and handheld computer.

At first glance, it might seem that the chassis type is interesting information but of minimal use to system administrators. In truth, however, knowing the physical design of the chassis provides valuable information for system administrators. After all, the physical design is a key factor in determining the type of hardware you can install on the computer; for example, disk drives that can be installed on a desktop computer are unlikely to fit in a subnotebook computer.

Knowing the chassis type of a computer can also be important for:

  • Applying Group Policy. Group Policy is often applied differently to computers with some chassis types. For example, software is typically installed in full on notebook computers rather than simply installed on first use. This ensures that a mobile user has available all the features of the software package.

  • Planning hardware upgrades. A computer that is going to be upgraded must be able to support the intended upgrade. Hard disks and network adapters designed for desktop computers do not work on notebook computers.

  • Planning hardware moves. If space is limited, you might prefer moving a mini-tower computer to a particular area rather than a full tower computer.

Traditionally, the only way to identify the chassis type has been by visual inspection. However, the Win32_SystemEnclosure class can be used to determine the chassis type of a computer. Chassis types are stored as an array consisting of one or more of the values shown in Table 8.6.

Table 8.6 Computer Chassis Values

Value

Description

1

Other

2

Unknown

3

Desktop

4

Low Profile Desktop

5

Pizza Box

6

Mini Tower

7

Tower

8

Portable

9

Laptop

10

Notebook

11

Hand Held

12

Docking Station

13

All in One

14

Sub Notebook

15

Space-Saving

16

Lunch Box

17

Main System Chassis

18

Expansion Chassis

19

Sub Chassis

20

Bus Expansion Chassis

21

Peripheral Chassis

22

Storage Chassis

23

Rack Mount Chassis

24

Sealed-Case PC

Scripting Steps

Listing 8.5 contains a script that identifies computer chassis type. 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_SystemEnclosure class.

    This query returns a collection consisting of the physical properties of the computer and its housing.

  4. For each set of physical properties in the collection, echo the chassis type.

    To do this, you must set up a For-Next loop to echo the values for the chassis type. The For-Next loop is required because the chassis type is stored as an array.

Listing 8.5 Identifying Computer Chassis Type

  
1
2
3
4
5
6
7
8
9
10
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_SystemEnclosure")
For Each objChassis in colChassis
 For Each intType in objChassis.ChassisTypes
 Wscript.Echo intType
 Next
Next

When the script in Listing 8.5 runs, the chassis type is reported as an integer. For example, if the computer has a mini-tower configuration, the value 6 is echoed to the screen. In a production script, a Select Case statement should be used to echo back string values as shown in the following code sample:

Case 6
Wscript.Echo "This computer is configured as a mini-tower."