Shell scripting is very limited when it comes to gathering system resource information. Most new devices are designed specifically to work with Windows, not DOS, and most resource configuration tools are GUI-controlled and not command-line controllable. However, there are still several tools and methods you can utilize to collect and report resource information through shell scripting.
SRVINFO is a resource kit utility to display various system information from the command line. The basic syntax of the SRVINFO command is:
SRVINFO / commands \computer
Here, computer is the name of the computer to collect information from, and the available commands are:
-D ”Displays service drivers
-NS ”Does not display service information
-S ”Displays shares
-V ”Displays Exchange and SQL version information
Here is an example to display all the information SRVINFO can report:
SRVINFO -S -V -D
To collect BIOS (Basic Input/Output System) information from the command line, you can use REG.EXE to extract the appropriate information. To display processor information using shell scripting, proceed as follows :
Create a new directory to store all files included in this example.
For Windows 2000 only, obtain REG.EXE from the Windows 2000 Resource Kit and copy it to the new directory.
Start a command prompt and enter " scriptfile .bat."
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
@ECHO OFF Reg Query HKLM\HARDWARE\DESCRIPTION\System\ SystemBiosVersion > BIOS.TXT Set Count =3 :Count For /f "tokens=% Count %" %% I in ('TYPE BIOS.TXT' ) Do Set Version =% Version % %% I Set /A Count +=1 If % Count % LSS 10 Goto Count Echo BIOS Version: % Version % Reg Query HKLM\HARDWARE\DESCRIPTION\System\ SystemBiosDate > BIOS.TXT For /f "tokens=3" %% I in ('TYPE BIOS.TXT' ) Do Echo BIOS Date: %% I Del BIOS.txt > Nul Set Count = Set Version =
| Note | The highlighted code above must be placed on one line. | 
| Related solution: | Found on page: | 
|---|---|
| Modifying the Registry with Shell Scripting | 124 | 
PSTAT is a Windows 2000 resource kit utility used to display running threads from the command line. You can use this tool to display memory information. To display memory information using shell scripting, proceed as follows:
Create a new directory to store all files included in this example.
Obtain PSTAT.EXE from the Resource Kit and copy it to the new directory.
Start a command prompt and enter " scriptfile .bat."
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
 PSTAT  Find " Memory: " > MEM.TXT For /F "tokens=2" %%  M  In ('Type MEM.txt') Do Echo Memory: %%  M  Del MEM.txt > Nul  To collect processor information from the command line, you can use REG.EXE to extract the appropriate information. To display processor information using shell scripting, proceed as follows:
Create a new directory to store all files included in this example.
For Windows 2000 only, obtain REG.EXE from the Windows 2000 Resource Kit and copy it to the new directory.
Start a command prompt and enter " scriptfile .bat."
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
  @ECHO OFF for /f "Tokens=4,5" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor   @ECHO OFF for /f "Tokens=4,5" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ family=%%j for /f "Tokens=6,7" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ model=%%j for /f "Tokens=8,9" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ step=%%j for /f "Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v ~MHZ') do set _ speed=%%j  SET /a speed=%speed% SET PType=Unknown IF %family% EQU 5 ( IF %model% LSS 4 SET PType=Pentium IF %model% GEQ 4 SET PType=Pentium MMX ) IF %family% EQU 6 ( IF %model% LSS 3 SET PType=Pentium Pro IF %model% GEQ 3 ( IF %model% LSS 5 ( SET PType=Pentium II ) IF %model% EQU 5 ( If %Step% EQU 0 Set PTYPE=Pentium II or Celeron If %Step% EQU 1 Set PTYPE=Pentium II or Celeron If %Step% EQU 2 Set PTYPE=Pentium II or Pentium II Xeon If %Step% EQU 3 Set PTYPE=Pentium II or Pentium II Xeon ) IF %model% EQU 6 SET PType=Celeron IF %model% GTR 6 SET PType=Pentium III or Pentium III Xeon IF %model% EQU A SET PType=Pentium III Xeon ) ) IF %family% EQU 15 ( IF %model% GEQ 0 SET PType=Pentium 4 ) ECHO Processor Type: %PType% ECHO Processor Speed: %SPEED% MHZ  " /v Identifier') do set_ family=%%j for /f "Tokens=6,7" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor   @ECHO OFF for /f "Tokens=4,5" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ family=%%j for /f "Tokens=6,7" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ model=%%j for /f "Tokens=8,9" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ step=%%j for /f "Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v ~MHZ') do set _ speed=%%j  SET /a speed=%speed% SET PType=Unknown IF %family% EQU 5 ( IF %model% LSS 4 SET PType=Pentium IF %model% GEQ 4 SET PType=Pentium MMX ) IF %family% EQU 6 ( IF %model% LSS 3 SET PType=Pentium Pro IF %model% GEQ 3 ( IF %model% LSS 5 ( SET PType=Pentium II ) IF %model% EQU 5 ( If %Step% EQU 0 Set PTYPE=Pentium II or Celeron If %Step% EQU 1 Set PTYPE=Pentium II or Celeron If %Step% EQU 2 Set PTYPE=Pentium II or Pentium II Xeon If %Step% EQU 3 Set PTYPE=Pentium II or Pentium II Xeon ) IF %model% EQU 6 SET PType=Celeron IF %model% GTR 6 SET PType=Pentium III or Pentium III Xeon IF %model% EQU A SET PType=Pentium III Xeon ) ) IF %family% EQU 15 ( IF %model% GEQ 0 SET PType=Pentium 4 ) ECHO Processor Type: %PType% ECHO Processor Speed: %SPEED% MHZ  " /v Identifier') do set_ model=%%j for /f "Tokens=8,9" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor   @ECHO OFF for /f "Tokens=4,5" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ family=%%j for /f "Tokens=6,7" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ model=%%j for /f "Tokens=8,9" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ step=%%j for /f "Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v ~MHZ') do set _ speed=%%j  SET /a speed=%speed% SET PType=Unknown IF %family% EQU 5 ( IF %model% LSS 4 SET PType=Pentium IF %model% GEQ 4 SET PType=Pentium MMX ) IF %family% EQU 6 ( IF %model% LSS 3 SET PType=Pentium Pro IF %model% GEQ 3 ( IF %model% LSS 5 ( SET PType=Pentium II ) IF %model% EQU 5 ( If %Step% EQU 0 Set PTYPE=Pentium II or Celeron If %Step% EQU 1 Set PTYPE=Pentium II or Celeron If %Step% EQU 2 Set PTYPE=Pentium II or Pentium II Xeon If %Step% EQU 3 Set PTYPE=Pentium II or Pentium II Xeon ) IF %model% EQU 6 SET PType=Celeron IF %model% GTR 6 SET PType=Pentium III or Pentium III Xeon IF %model% EQU A SET PType=Pentium III Xeon ) ) IF %family% EQU 15 ( IF %model% GEQ 0 SET PType=Pentium 4 ) ECHO Processor Type: %PType% ECHO Processor Speed: %SPEED% MHZ  " /v Identifier') do set_ step=%%j for /f "Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor   @ECHO OFF for /f "Tokens=4,5" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ family=%%j for /f "Tokens=6,7" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ model=%%j for /f "Tokens=8,9" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v Identifier') do set_ step=%%j for /f "Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\_ DESCRIPTION\System\CentralProcessor\0" /v ~MHZ') do set _ speed=%%j  SET /a speed=%speed% SET PType=Unknown IF %family% EQU 5 ( IF %model% LSS 4 SET PType=Pentium IF %model% GEQ 4 SET PType=Pentium MMX ) IF %family% EQU 6 ( IF %model% LSS 3 SET PType=Pentium Pro IF %model% GEQ 3 ( IF %model% LSS 5 ( SET PType=Pentium II ) IF %model% EQU 5 ( If %Step% EQU 0 Set PTYPE=Pentium II or Celeron If %Step% EQU 1 Set PTYPE=Pentium II or Celeron If %Step% EQU 2 Set PTYPE=Pentium II or Pentium II Xeon If %Step% EQU 3 Set PTYPE=Pentium II or Pentium II Xeon ) IF %model% EQU 6 SET PType=Celeron IF %model% GTR 6 SET PType=Pentium III or Pentium III Xeon IF %model% EQU A SET PType=Pentium III Xeon ) ) IF %family% EQU 15 ( IF %model% GEQ 0 SET PType=Pentium 4 ) ECHO Processor Type: %PType% ECHO Processor Speed: %SPEED% MHZ  " /v ~MHZ') do set _ speed=%%j  SET /a speed=%speed% SET PType=Unknown IF %family% EQU 5 (   IF %model% LSS 4 SET PType=Pentium   IF %model% GEQ 4 SET PType=Pentium MMX ) IF %family% EQU 6 (   IF %model% LSS 3 SET PType=Pentium Pro   IF %model% GEQ 3 (     IF %model% LSS 5 (       SET PType=Pentium II     )     IF %model% EQU 5 (       If %Step% EQU 0 Set PTYPE=Pentium II or Celeron       If %Step% EQU 1 Set PTYPE=Pentium II or Celeron       If %Step% EQU 2 Set PTYPE=Pentium II or Pentium II Xeon       If %Step% EQU 3 Set PTYPE=Pentium II or Pentium II Xeon     )     IF %model% EQU 6 SET PType=Celeron     IF %model% GTR 6 SET PType=Pentium III or Pentium III Xeon     IF %model% EQU A SET PType=Pentium III Xeon   ) ) IF %family% EQU 15 (   IF %model% GEQ 0 SET PType=Pentium 4 ) ECHO Processor Type: %PType% ECHO Processor Speed: %SPEED% MHZ  | Note | The highlighted code on the previous page must be placed on one line. The routine to determine the processor type was derived from various Intel processor spec sheets. | 
KiXtart provides many macros to retrieve user information, but only a few of these macros can be used to retrieve resource information. By combining KiXtart macros and registry commands, you can collect and report various resource information through simple scripts.
KiXtart does not provide any direct method to collect BIOS information. Alternatively, you can query the registry and extract the BIOS information you want using KiXtart. To collect printer information using KiXtart, proceed as follows:
Create a new directory to store all files included in this example.
Download and extract the latest version of KiXtart, from http://www.kixtart.org, to the new directory.
Select StartRun and enter "kix32 scriptfile. "
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
; Get the system BIOS type $SBiosType = READVALUE("HKEY_LOCAL_MACHINE\HARDWARE\ DESCRIPTION\System","SystemBiosVersion") ; Get the system BIOS date $SBiosDate = READVALUE("HKEY_LOCAL_MACHINE\HARDWARE\ DESCRIPTION\System","SystemBiosDate") ? "BIOS Type: $SBiosType " ? "BIOS Date: $SBiosDate " SLEEP 10
| Note | The highlighted code above must be placed on one line. | 
| Related solution: | Found on page: | 
|---|---|
| Modifying the Registry with KiXtart | 129 | 
Although KiXtart provides no built-in method to determine all system drives and their total size , you can perform checks for available drives and free disk space. An available drive is considered to be any drive with media present. For example, a drive without a floppy or CD-ROM is an unavailable drive. To collect information on available drives using KiXtart, proceed as follows.
Create a new directory to store all files included in this example.
Download and extract the latest version of KiXtart, from http://www.kixtart.org, to the new directory.
Select StartRun and enter "kix32 scriptfile. "
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
 $  DLetter  = 67 While $  DLetter  < 91   $  Drive  = CHR($  DLetter  ) + ":" If Exist ($  Drive  )   $  DiskSpace  = GETDISKSPACE($  Drive  )   SELECT     CASE $  DiskSpace  = 0       $  DiskSpace  = "0 Bytes"     CASE $  DiskSpace  < 1024       $  DiskSpace  = $  DiskSpace  * 100       $  DiskSpace  = "$  DiskSpace  KB"     CASE $  DiskSpace  => 1024 and $  DiskSpace  < 1048576       $  DiskSpace  = ($  DiskSpace  * 100) / 1024       $  DiskSpace  = "$  DiskSpace  MB"     CASE $  DiskSpace  => 1048576       $  DiskSpace  = $  DiskSpace  / 10486       $  DiskSpace  = "$  DiskSpace  GB"     ENDSELECT  $  DiskSpace  = SUBSTR($  DiskSpace  , 1, LEN($  DiskSpace  ) - 5)      + "." + SUBSTR($  DiskSpace  ,LEN($  DiskSpace  )-4, 5)  ?"Drive $  Drive  Free Space: $  DiskSpace  "   EndIf   $  DLetter  = $  DLetter  + 1 Loop Sleep 5  | Note | The highlighted code above must be placed on one line. | 
Notice that the drive letter count ( $ Dletter ) starts at 67 and runs until 91. These numbers represent ASCII characters C to Z. If you start $ Dletter with 65 (A), your script might pause and you might be prompted for a floppy disk if none is present.
To collect OS information using KiXtart, proceed as follows:
Create a new directory to store all files included in this example.
Download and extract the latest version of KiXtart, from http://www.kixtart.org, to the new directory.
Select StartRun and enter "kix32 scriptfile. "
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
; Initialize variables $ SUITE = "" SELECT ; Product Suite? CASE @PRODUCTSUITE = 1 $ SUITE = "Small Business" CASE @PRODUCTSUITE = 2 $ SUITE = "Enterprise" CASE @PRODUCTSUITE = 4 $ SUITE = "BackOffice" CASE @PRODUCTSUITE = 8 $ SUITE = "CommunicationServer" CASE @PRODUCTSUITE = 16 $ SUITE = "Terminal Server" CASE @PRODUCTSUITE = 32 $ SUITE = "Small Business (Restricted)" CASE @PRODUCTSUITE = 64 $ SUITE = "EmbeddedNT" CASE @PRODUCTSUITE = 128 $ SUITE = "DataCenter" CASE @PRODUCTSUITE = "256" $ SUITE = "Single user Terminal Server" CASE @PRODUCTSUITE = 512 $ SUITE = "Home Edition" CASE @PRODUCTSUITE = 1024 $ SUITE = "Blade Server" CASE 1 $ SUITE = "UNDETERMINED" ENDSELECT ? "Operating System: @PRODUCTTYPE" ; Display OS type ? "Build: @BUILD" ; Display the build number ? "Suite: " + $ SUITE ; Display the product suite ? "Service Pack: @CSD" ; Display the service pack SLEEP 10
KiXtart does not provide any direct method to collect information about all the printers installed on a system. Alternatively, you can query the registry and extract the printer information you want using KiXtart. To collect printer information using KiXtart, proceed as follows:
Create a new directory to store all files included in this example.
Download and extract the latest version of KiXtart, from http://www.kixtart.org, to the new directory.
Select StartRun and enter "kix32 scriptfile. "
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
  $  Printers  ="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Control\Print\Printers\"  $  Index  =0 :GatherInfo $  Printer  =enumkey("$  Printers  ",$Index) If @Error=0   $  Desc  = Readvalue("$  Printers  $  Printer  ","Description")   $  Loc  = Readvalue("$  Printers  $  Printer  ","Location")   $  Port  = Readvalue("$  Printers  $  Printer  ","Port")   $  Share  = Readvalue("$  Printers  $  Printer  ","Share Name")   ? "Printer: $  Printer  "   ? "Description: $  Desc  "   ? "Location: $  Loc  "   ? "Port: $  Port  "   ? "Share: $  Share  "   ?   ?$  Index  = $  Index  + 1   Goto GatherInfo EndIf Sleep 10  | Note | The highlighted code above must be placed on one line. | 
KiXtart includes the @CPU and @MHZ macros to provide the name and speed of the primary processor installed on a system. Additionally, you can query the registry and extract the processor count using KiXtart. To collect processor information using KiXtart, proceed as follows:
Create a new directory to store all files included in this example.
Download and extract the latest version of KiXtart, from http://www.kixtart.org, to the new directory.
Select StartRun and enter "kix32 scriptfile. "
Here, scriptfile is the full path of the new directory from step 1 and file name of a script file that contains the following:
 ;  Get the number of processors $  ProCount  = 0 $  Count  = 0 WHILE $  Count  < 65  $  ProTemp  = EXISTKEY("HKEY_LOCAL_MACHINE\HARDWARE\   DESCRIPTION\System\CentralProcessor$ProCount")  IF $  ProTemp  = 0     $  ProCount  = $  ProCount  + 1   ENDIF   $  Count  = $  Count  + 1 LOOP ; The code below is to simply display the final results ? "Processor Count: $  ProCount  " ? "Processor Name: " + TRIM(@CPU) ? "Processor Speed: @MHZ MHZ" SLEEP 10  | Note | The highlighted code above must be placed on one line. | 
Windows Management Instrumentation provides centralized management system for almost all the resources on your system. Through various WMI classes and Windows Script Host, you can collect and report various resource information through simple scripts.
| Tip | The examples in the following sections illustrate only a few of the classes and class properties that WMI has to offer. Consult the WMI SDK documentation for a complete list of classes and their properties. | 
The Win32_Battery class allows you to query laptop battery and Uninterruptible Power Supply (UPS) information through WMI. To collect battery information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
Set BatterySet = GetObject("winmgmts:").InstancesOf ("Win32_Battery") For each Battery in BatterySet Select Case Battery .Chemistry Case 1 BType = "Other" Case 2 BType = "Unknown" Case 3 BType = "Lead Acid" Case 4 BType = "Nickel Cadmium" Case 5 BType = "Nickel Metal Hydride" Case 6 BType = "Lithium-ion" Case 7 BType = "Zinc air" Case 8 BType = "Lithium Polymer" End Select Select Case Battery .BatteryStatus Case 1 BStatus = "Other" Case 2 BStatus = "Unknown" Case 3 BStatus = "Fully Charged" Case 4 BStatus = "Low" Case 5 BStatus = "Critical" Case 6 BStatus = "Charging" Case 7 BStatus = "Charging and High" Case 8 BStatus = "Charging and Low" Case 9 BStatus = "Charging and Critical" Case 10 BStatus = " Undefined " Case 11 BStatus = "Partially Charged" End Select WScript.Echo "Name: " & Battery .Description & VBlf & _ "Type: " & BType & VBlf & _ "% Left: " & Battery .EstimatedChargeRemaining & VBlf & _ "Minutes Left: " & Battery .ExpectedLife & VBlf & _ "Status: " & BStatus Next
| Note | The highlighted code above must be placed on one line. | 
The Win32_BIOS class allows you to query BIOS information through WMI. To collect BIOS information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  BIOSSet  = GetObject("winmgmts:").InstancesOf ("Win32_BIOS")  For each  BIOS  in  BIOSSet   BDate  = Left(  BIOS  .ReleaseDate,8)  BDate  = Mid(  BDate  ,5,2) & "/" & Mid(  BDate  ,7,2) & "/" & _   Mid(  BDate  ,1,4)   WScript.Echo "Name: " &  BIOS  .Name & VBlf & _   "Manufacturer: " &  BIOS  .Manufacturer & VBlf & _   "Date: " &  BDate  & VBlf & _   "Version: " &  BIOS  .Version & VBlf & _   "Status: " &  BIOS  .Status Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_CDROMDrive class allows you to query CD-ROM information through WMI. To collect CD-ROM information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  CDSet  = GetObject("winmgmts:").InstancesOf ("Win32_CDROMDrive")  For each  CD  in  CDSet  WScript.Echo "Name: " &  CD  .Name & VBlf & _   "Drive: " &  CD  .Drive & VBlf & _   "Status: " &  CD  .Status Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_SystemEnclosure class allows you to query system enclosure information through WMI. To collect system enclosure information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
 Set  SystemSet  = GetObject("winmgmts:").InstancesOf ("Win32_SystemEnclosure") For each  Chassis  in  SystemSet  For Each  ChassisType  in  Chassis  .ChassisTypes     Select Case  ChassisType  Case 1         Wscript.Echo "Other"       Case 2         Wscript.Echo "Unknown"       Case 3         Wscript.Echo "Desktop"       Case 4         Wscript.Echo "Low Profile Desktop"       Case 5         Wscript.Echo "Pizza Box"       Case 6         Wscript.Echo "Mini Tower"       Case 7         Wscript.Echo "Tower"       Case 8         Wscript.Echo "Portable"       Case 9         Wscript.Echo "Laptop"       Case 10         Wscript.Echo "Notebook"       Case 11         Wscript.Echo "Hand Held"       Case 12         Wscript.Echo "Docking Station"       Case 13         Wscript.Echo "All in One"       Case 14         Wscript.Echo "Sub Notebook"       Case 15         Wscript.Echo "Space-Saving"       Case 16         Wscript.Echo "Lunch Box"       Case 17         Wscript.Echo "Main System Chassis"       Case 18         Wscript.Echo "Expansion Chassis"       Case 19         Wscript.Echo "SubChassis"       Case 20         Wscript.Echo "Bus Expansion Chassis"       Case 21         Wscript.Echo "Peripheral Chassis"       Case 22         Wscript.Echo "Storage Chassis"       Case 23         Wscript.Echo "Rack Mount Chassis"       Case 24         Wscript.Echo "Sealed-Case PC"     End Select   Next Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_LogicalDisk class allows you to query disk information through WMI. To inventory disks on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  DiskSet  = GetObject("winmgmts:").InstancesOf ("Win32_LogicalDisk")  For each  Disk  in  DiskSet  Select Case  Disk  .DriveType   Case 0  DType  = "Unknown"   Case 1     DType = "No Root Directory"   Case 2     DType = "Removable Disk"   Case 3  DType  = "Local Disk"   Case 4  DType  = "Network Drive"   Case 5  DType  = "Compact Disc"   Case 6  DType  = "RAM Disk"   End Select   WScript.Echo "Drive: " &  Disk  .DeviceID & VBlf & _   "Name: " &  Disk  .Description & VBlf & _   "Type: " &  DType  & VBlf & _   "File System: " &  Disk  .FileSystem & VBlf & _   "Size: " &  Disk  .Size & VBlf & _   "Free Space: " &  Disk  .FreeSpace & VBlf & _   "Compressed: " &  Disk  .Compressed Next  | Note | The highlighted code on the previous page must be placed on one line. | 
The Win32_LogicalMemoryConfiguration class allows you to query memory information through WMI. To collect memory information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  MemorySet  = GetObject("winmgmts:").InstancesOf. ("Win32_LogicalMemoryConfiguration")  For each  Memory  in  MemorySet  WScript.Echo "Total: " & _  Memory  .TotalPhysicalMemory/1024 & VBlf & _   "Virtual: " &  Memory  .TotalVirtualMemory/1024 & VBlf & _   "Page: " &  Memory  .TotalPageFileSpace/1024 Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_POTSModem class allows you to query modem information through WMI. To collect modem information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  ModemSet  = GetObject("winmgmts:").InstancesOf ("Win32_POTSModem")  For each  Modem  in  ModemSet  WScript.Echo "Name: " &  Modem  .Name & VBlf & _   "Port: " &  Modem  .AttachedTo & VBlf & _   "Type: " &  Modem  .DeviceType & VBlf & _   "Status: " &  Modem  .Status Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_DesktopMonitor class allows you to query information on computer monitors through WMI. To collect monitor information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  MonitorSet  = GetObject("winmgmts:").InstancesOf ("Win32_DesktopMonitor")  For each  Monitor  in  MonitorSet  WScript.Echo "Name: " &  Monitor  .Name & VBlf & _   "Height: " &  Monitor  .ScreenHeight & VBlf & _   "Width: " &  Monitor  .ScreenWidth & VBlf & _   "Status: " &  Monitor  .Status Next  | Note | The highlighted code on the previous page must be placed on one line. | 
The Win32_PointingDevice class allows you to query mouse, trackball , touch screen, touch pad, and other pointing device information through WMI. To collect pointing device information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  MouseSet  = GetObject("winmgmts:").InstancesOf ("Win32_PointingDevice")  For each  Mouse  in  MouseSet  WScript.Echo "Name: " &  Mouse  .Name & VBlf & _   "Manufacturer: " &  Mouse  .Manufacturer & VBlf & _   "Type: " &  Mouse  .HardwareType & VBlf & _   "Buttons: " &  Mouse  .NumberofButtons & VBlf & _   "Status: " &  Mouse  .Status Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_NetworkAdapter class allows you to query information on network adapters through WMI. To collect Network Interface Card (NIC) information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  NICSet  = GetObject("winmgmts:").InstancesOf ("Win32_NetworkAdapter")  For each  NIC  in  NICSet  WScript.Echo "Name: " &  NIC  .Name & VBlf & _   "Type: " &  NIC  .AdapterType & VBlf & _   "Speed: " &  NIC  .Speed & VBlf & _   "MAC: " &  NIC  .MACAddress & VBlf & _   "Addresses: " &  NIC  .NetworkAddresses Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_OperatingSystem class allows you to query various operating system information through WMI. To collect CD-ROM information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  OSSet  = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")  For each  OS  in  OSSet  WScript.Echo "OS: " &  OS  .Caption & VBlf & _   "Build: " &  OS  .BuildNumber & VBlf & _   "Version: " &  OS  .Version & VBlf & _   "Service Pack: " &  OS  .CSDVersion & VBlf & _   "ProdID: " &  OS  .SerialNumber & VBlf & _   "Install Date: " &  OS  .InstallDate & VBlf & _   "Last Bootup: " &  OS  .LastBootUpTime Next  | Note | The highlighted code on the previous page must be placed on one line. | 
The Win32_Printer class allows you to query printer information through WMI. To collect printer information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  PrinterSet  = GetObject("winmgmts:").InstancesOf ("Win32_Printer")  For each  Printer  in  PrinterSet  WScript.Echo "Name: " &  Printer  .Name & VBlf & _   "Location: " &  Printer  .Location & VBlf & _   "Share: " &  Printer  .ShareName & VBlf & _   "Status: " &  Printer  .Status Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_Processor class allows you to query processor information through WMI. To collect processor information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  ProSet  = GetObject("winmgmts:").InstancesOf ("Win32_Processor")  For each  Pro  in  ProSet  WScript.Echo "Name: " &  Pro  .Name & VBlf & _   "Speed: " &  Pro  .MaxClockSpeed & VBlf & _   "Cache: " &  Pro  .L2CacheSize & " Cache" & VBlf & _   "Processor ID: " &  Pro  .ProcessorId Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_SoundDevice class allows you to query sound card information through WMI. To collect sound card information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  SoundSet  = GetObject("winmgmts:").InstancesOf ("Win32_SoundDevice")  For each  Sound  in SoundSet   WScript.Echo "Card: " &  Sound  .ProductName & VBlf & _   "Manufacturer: " &  Sound  .Manufacturer Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_TapeDrive class allows you to query tape drive information through WMI. To collect tape drive information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  TapeSet  = GetObject("winmgmts:").InstancesOf ("Win32_TapeDrive")  For each  Tape  in  TapeSet  WScript.Echo "Name: " &  Tape  .Name & VBlf & _   "Hardware Compression: " &  Tape  .Compression & VBlf & _   "Needs Cleaning: " &  Tape  .NeedsCleaning & VBlf & _   "Status: " &  Tape  .Status Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_PnPEntity class allows you to query USB device information through WMI. To collect USB device information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  USBSet  = GetObject("winmgmts:").InstancesOf ("Win32_PnPEntity")  For each  USB  in  USBSet  WScript.Echo "Name: " &  USB  .Name & VBlf & _   "Manufacturer: " &  USB  .Manufacturer Next  | Note | The highlighted code on the previous page must be placed on one line. | 
The Win32_VideoController class allows you to query video card information through WMI. To collect video card information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com , to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  VideoSet  = GetObject("winmgmts:").InstancesOf ("Win32_VideoController")  For each  Video  in  VideoSet  WScript.Echo "Card: " &  Video  .Description & VBlf & _   "Current: " &  Video  .VideoModeDescription Next  | Note | The highlighted code above must be placed on one line. | 
The Win32_Product class allows you to query installed software information through WMI. This class can only retrieve information on products installed with the Windows installer. To collect Installed software information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  Software  = GetObject("winmgmts:").InstancesOf ("Win32_Product")  For each  Application  in  Software  Wscript.Echo "Name: " &  Application  .Name & VBCRLF & _   "Vendor: " &  Application  .Vendor & VBCRLF & _   "Install Date: " & Mid(  Application  .InstallDate2, 5, 2) & "/" & _   Mid(  Application  .InstallDate2, 7, 2) & "/" & _   Mid(  Application  .InstallDate2, 1, 4) Next  | Note | The highlighted code on the previous page must be placed on one line. | 
The Win32_QuickFixEngineering class allows you to query installed hotfix and update information through WMI. To collect installed software information on a system using WMI, proceed as follows:
Create a new directory to store all files included in this example.
Download and install the latest version of Windows Script Host, from http://www.microsoft.com, to the new directory.
Select StartRun and enter "cscript scriptfile .vbs."
Here, scriptfile is the full path and file name of a script file that contains the following:
  Set  HotFixes  = GetObject("winmgmts:").InstancesOf ("Win32_QuickFixEngineering")  For each  HotFix  in  HotFixes  Wscript.Echo "ID: " &  HotFix  .HotFixID & VBCRLF & _   "Description: " &  HotFix  .Description Next  | Note | The highlighted code above must be placed on one line. | 
