With WMI Object on windows, it is easy to retrieve hardware information via SQL-like query, for example, the following query retrieves the keyboard information.
Select * from Win32_Keyboard
The following VBScript runs at Windows Script Host (and you could use Microsoft JScript or other programming languages to do the same thing).
' List Keyboard Properties
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Keyboard")
For Each objItem in colItems
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Device ID: " & objItem.DeviceID
Wscript.Echo "Is Locked: " & objItem.IsLocked
Wscript.Echo "Layout: " & objItem.Layout
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Number of Function Keys: " & objItem.NumberOfFunctionKeys
Wscript.Echo "Password: " & objItem.Password
Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Next
It outputs the following on my PC where I use the Razer BlackWidow Keyboard.
Caption: Enhanced (101- or 102-key)
Description: Razer BlackWidow
Device ID: USB\VID_1532&PID_011B&MI_00\6&31CE2353&0&0000
Is Locked:
Layout: 00000409
Name: Enhanced (101- or 102-key)
Number of Function Keys: 12
Password:
PNP Device ID: USB\VID_1532&PID_011B&MI_00\6&31CE2353&0&0000
Caption: Enhanced (101- or 102-key)
Description: HID Keyboard Device
Device ID: HID\VID_1532&PID_011B&MI_01&COL01\7&358259A0&0&0000
Is Locked:
Layout: 00000409
Name: Enhanced (101- or 102-key)
Number of Function Keys: 12
Password:
PNP Device ID: HID\VID_1532&PID_011B&MI_01&COL01\7&358259A0&0&0000
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: How to List Memory Devices in VBScript?
Next Post: How to List Process Owners using VBScript + WMI Object?