hwdetect.exe

The hwdetect (hardware detect) utility performs basic hardware detection functions that are typically obtained by using SMBIOS and a PCI scan.

Thhwdetect utility has options that can be used to dump all of the hardware information to an output file, or it can be used to query hardware information and return values that set the errorlevel environment variable or the return code in Windows PE.

hwdetect performs basic hardware scan functions and more complex PCI device detection options. The basic hardware scan functions can only be used singularly. The PCI device detection functions may be used in combination with each other to produce a query based on multiple restrictions.

You can only use the hwdetect utility basic hardware scan functions one at a time. The PCI-device detection functions can be combined or used more than once on the same command line.

Two versions of the utility come with ServerGuide Scripting Toolkit:
The hwdetect utility command-line syntax:
hwdetect [/s|/p|/i|/m:type] [/vid:vendor_id] [/did:device_id] [/svid:sub_vendor_id]
[/sdid:sub_device_id] [bn:bus_number] [/dn:device_number] [/add:num]
Table 1. hwdetect parameters
Parameter Description
Basic hardware scan functions
/s
Determines if the target server is a LenovoeServer or LenovoeServerxSeries server. The return values are:
  • 0 for a LenovoeServer or LenovoeServerxSeries server
  • 1 for a non-LenovoeServer or LenovoeServerxSeries server
/p
  • Displays all hardware information for the target server in a variable=value format.
  • The return value is 0 when successful.
  • You can use the > output-redirect option to save the output to an output file. For example, hwdetect /p > filename.
/i
  • Displays all hardware information for the target server in an INI-file format.
  • The return value is 0 when successful.
  • You can use the > output-redirect option to save the output to an output file.
/m:type
Compares the machine type of the target xSeries server to the specified machine type, type. The return values are:
  • 0 when the machine types are different or no basis for comparison exists
  • 1 when the machine types match

Parameter Description
PCI-device detection functions
/vid:vendor_id
  • Determines whether there is a PCI adapter in the target server that matches the specified vendor ID, where vendor_id is a hexadecimal value.
  • The return value is the number of matching adapters in the target server, or 0 if there are no matches.
/did:device_id
  • Determines whether there is a PCI adapter in the target server that matches the specified device ID, where device_id is a hexadecimal value.
  • The return value is the number of matching adapters in the target server, or 0 if there are no matches.
/svid:sub_vendor_id
  • Determines whether there is a PCI adapter in the target server that matches the specified sub-vendor ID, where subvendor_id is a hexadecimal value.
  • The return value is the number of matching adapters in the target server, or 0 if there are no matches.
/sdid:sub_device_id
  • Determines whether there is a PCI adapter in the target server that matches the specified sub-device ID, where subdevice_id is a hexadecimal value.
  • The return value is the number of matching adapters in the target server, or 0 if there are no matches.
/bn:bus_number
  • Causes the PCI scan to begin at the specified bus number, instead of starting at bus 0, by default.
  • This parameter is only valid when more than one /vid, /did, /svid, or /sdid parameter is specified on the command line.
/dn:device_number
  • Causes the PCI scan to begin at the specified device number, instead of starting at device number 0, by default.
  • This parameter is only valid when the /bn parameter is specified on the command line.
/add:num
  • Adds an integer number, num, to the return value before exiting.
  • This is useful to obtain a sum of different PCI adapters, with different PCI IDs, in a target server.
  • The return value is the resultant sum of all other return values plus num.
The following examples illustrate hwdetect utility usage.
Table 2. hwdetect examples
Example Description
hwdetect /s
if errorlevel 1 goto NONLenovo
if errorlevel 0 goto Lenovo

:NONLenovo
rem Perform non-Lenovo equipment specific steps here
goto FINISH

:Lenovo
rem Perform Lenovo equipment specific steps here

:FINISH
Determines if the target server is a Lenovo server or not, and branches accordingly to perform equipment-specific steps
hwdetect /m:8676
if errorlevel 1 goto 8676

hwdetect /m:8669
if errorlevel 1 goto 8669

echo System not supported!
goto done

:8676
call 8676.bat
goto done

:8669
call 8669.bat
goto done

:done
Determines if the target server is either a machine type 8676 or machine type 8669 server, and branches accordingly to call a system-specific batch file or displays a message of not supporting other machine types
hwdetect /i>hwdetect.out
clini hwdetect.out /S:CI /I:Vendor_ID.0 /E:Vendor
CLIniSet.bat
Creates an output file that lists the hardware configuration for the target server, so that the clini utility can search for a specific PCI adapter from a vendor and set en environment variable accordingly
hwdetect /vid:0x9005 /did:0x0250
if errorlevel 1 call 6Mstuff.bat
Determines if there is at least one IBM ServeRAID 6i/6i+/6M PCI adapter in the target server, and calls a batch file to process adapter-specific tasks
hwdetect /vid:0x9005 /did:0x0250
if errorlevel 0 set TOTAL=0
if errorlevel 1 set TOTAL=1
if errorlevel 2 set TOTAL=2
if errorlevel 3 set TOTAL=3

hwdetect /add:%TOTAL% /vid:0x1014 /did:0x01BD
if errorlevel 0 set TOTAL=0
if errorlevel 1 set TOTAL=1
if errorlevel 2 set TOTAL=2
if errorlevel 3 set TOTAL=3
if errorlevel 4 set TOTAL=4
if errorlevel 5 set TOTAL=5
if errorlevel 6 set TOTAL=6

echo There are %TOTAL% Lenovo ServeRAID adapters in
this system
Determines the total number of Lenovo ServeRAID adapters in the target server, assuming there are no more than three of each type: Lenovo ServeRAID 4, Lenovo ServeRAID 5, and Lenovo ServeRAID 6/6i/6M
hwdetect /i>hwdetect.out
  • Displays hardware configuration information about the target server.
  • The >hwdetect.out parameter is a Windows output-redirect option that causes the output from the hwdetect utility to be saved in the specified file.
Below is an example of the hwdetect.out file using the last parameter in the table above:
[System]
Machine_Type=8674
Model_Number=42X
Serial_Number=78Z9506
Product_Name=eserver xSeries 330
BIOS_version=1.04
BIOS_Build_Level=EME112A
BIOS_DATE=06/28/2002  
BIOS_Manufacturer=Lenovo
BIOS_Language=US
Number_Of_Enclosures=1
Enclosure_Type.0=23 
Processor_Slots=2
Active_Processors=1
Processor_Family.0=17    
Processor_Speed_MHz.0=1400 
Processor_X64 = TRUE
Total_Enabled_Memory_Mb=256
ROM_Diagnostics_Build_Level=EME112A
ISMP_Build_Level=BR8T30A
RSA_Build_Level=GEE834A
System_UUID = 8030E01060F010B010605090D0A020F0
Blade_Chassis_UUID = 0F020A0D0900F00F020A0D0900F00F02
Blade_Slot = 02

[PCI]                 
Total_Number_Devices=10
Bus_Number.0=0       
Device_Number.0=1
Function_Number.0=0
Class_Code.0=0000
Revision.0=0
Header_Type.0=0
Vendor_ID.0=5333     
Device_ID.0=8A22
Subvendor_ID.0=1014
Subdevice_ID.0=01C5
Bus_Number.1=0
Device_Number.1=2
Function_Number.1=0
Class_Code.1=0000
Revision.1=0
Header_Type.1=0
Vendor_ID.1=8086
Device_ID.1=1229
Subvendor_ID.1=1014
Subdevice_ID.1=105C

Running hwdetect /p produces the same output with the exception that the section names are tacked onto the beginning of each keyword:
System_Machine_Type = 8674
System_Model_Number = 42X
System_Serial_Number = 78Z9506

PCI_Bus_Number.0 = 0 
PCI_Device_Number.0 = 1   
...
Notes:
  1. The BIOS_DATE value is listed in mm/dd/yyyy format.
  2. The Enclosure_Type.0=23 is based on SMBIOS 2.3 spec. 23 = Main chassis.
  3. There is an entry for Processor_Family and Processor_Speed_MHz for each microprocessor in the server.
  4. The ROM_Diagnostics_Build_Level is empty for servers that do not support ROM diagnostics.
  5. PCI devices are listed in the order they are scanned.
  6. PCI devices are listed in the Value.n format, where Value is the variable name and n is the nth PCI device scanned.
  7. The header_type field is not available for versions of hwdetect running on Windows 32 or 64-bit operating systems.
  8. The vendor, device, subvendor, and subdevice values are in hexadecimal notation.