Identifying the Chassis Type of a Computer

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

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

ValueDescription
1Other
2Unknown
3Desktop
4Low Profile Desktop
5Pizza Box
6Mini Tower
7Tower
8Portable
9Laptop
10Notebook
11Hand Held
12Docking Station
13All in One
14Sub Notebook
15Space-Saving
16Lunch Box
17Main System Chassis
18Expansion Chassis
19Sub Chassis
20Bus Expansion Chassis
21Peripheral Chassis
22Storage Chassis
23Rack Mount Chassis
24Sealed-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." 

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net