Fingerprint

  • Thread starter Thread starter TerryM
  • Start date Start date
TerryM said:
How can I query in WMI to see if a fingerprint reader is installed?

Thanks,
Terry


Terry,

If your fingerprint reader is a USB device you could enumerate all
of the USB devices by querying the Win32_USBControllerDevice class and
then use the returned device IDs to query the Win32_PnPEntity class.
Loop through each of the devices looking for a match to a keyword (you
would need to know some portion of the device name).

If this kludge will work for you try this function. Call it by passing
a computer name and a search term as strings. Perhaps "fingerprint" or
"finger" would work?

--------------------------
If SearchUSBDevices(".","fingerprint") <> "Not Found" Then
'put your code here
MsgBox "Found a device matching your search term!"
End If

Function SearchUSBDevices(strComputer, strSearchTerm)
'Accepts a computer name and search term as strings
'Returns the name of a USB device matching the search term
'or returns "Not Found" if no matching device could be found
Dim objWMIService, objItem, SWBemlocator, colItems, wshShell
Dim colUSBDevices, objUSBDevice, colDescriptions, objDescription
On Error Resume Next
Set wshShell = CreateObject("Wscript.Shell")
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer _
(strComputer,"root\CIMV2")
'Enumerate all of the usb devices
Set colUSBDevices = objWMIService.ExecQuery _
("Select * From Win32_USBControllerDevice")
For Each objUSBDevice In colUSBDevices
If Err.Number = 0 Then
'Get the device ID & query Win32_PnPEntity for devices
'matching the strSearchTerm
intPos = InStr(1, objUSBDevice.Dependent, ".")
strDeviceID = Right(objUSBDevice.Dependent, _
Len(objUSBDevice.Dependent) - intPos)
Set colDescriptions = objWMIService.ExecQuery _
("Select * From Win32_PnPEntity " & _
"Where " & strDeviceID)
For Each objDescription In colDescriptions
If InStr(LCase(objDescription.Caption), _
LCase(strSearchTerm)) Then
SearchUSBDevices = objDescription.Caption
Else
SearchUSBDevices = "Not Found"
End If
Next
Else
SearchUSBDevices = "Not Found"
End If
Next
End Function
 
Back
Top