cancel
Showing results for 
Search instead for 
Did you mean: 
EdT
Level 6

Have you ever tried to get a build created with all the required device drivers, and have found that there are one or two yellow question marks that you cannot find the correct drivers for?

Yes, we've all been there at sometime.

To help me with this situation when new machines, demo or otherwise, arrive at my clients, I have developed a utility which you run on the pre-installed operating system, which records all the Device ID's and the associated driver information. Although this does not guarantee a 100% solution for all situations, being able to identify driver information based on the device ID associated with a yellow question mark in device manager, often leads to a quick solution.

The VBScript code relies on a couple of WMI functions - Win32_PnPEntity and Win32_PnPSignedDriver. It is run from the Windows operating system installed by the manufacturer, which will have all required device drivers installed.

When the code runs, it will ask for a machine name to identify the hardware you are running on. Enter a model name or number - whichever is the most memorable. The resultant file will be saved in the same folder as the script.

Code for PnPEntity.vbs:

Const ForReading = 1, ForWriting = 2
Dim fso, f, input
input = InputBox("Enter the Machine Name", "PNPEntity Grabber Program", "Testfile")
Set fso = CreateObject("Scripting.FileSystemObject")
'Set f = fso.OpenTextFile("D:\WMI Scripts\testfile.txt", ForWriting, True)
'Set f = fso.OpenTextFile("testfile.txt", ForWriting, True)
Set f = fso.OpenTextFile(input&"-PNPEntities.txt", ForWriting, True)
f.WriteLine "PNPEntity scan for model: "&input
f.WriteLine ""

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPEntity") '& "WHERE Caption <> 0")
Set infItems = objWMIService.ExecQuery("Select * from Win32_PnPSignedDriver Where InfName <> null")

For Each objItem in colItems
f.WriteLine "Manufacturer: " & objItem.Manufacturer
f.WriteLine "Name: " & objItem.Name
f.WriteLine "Description: " & objItem.Description
f.WriteLine "Class GUID: " & objItem.ClassGuid
f.WriteLine "PNP Device ID: " & objItem.PNPDeviceID
'f.WriteLine "Device ID: " & objItem.DeviceID
For Each Item in infItems
If objItem.DeviceID = Item.DeviceID then
f.WriteLine "Device Class: " & Item.DeviceClass
f.WriteLine "Hardware ID: " & Item.HardwareID
f.WriteLine "Inf Name: " & Item.InfName
End If
Next
f.WriteLine "Service: " & objItem.Service
f.WriteLine ""
Next
' f.WriteLine "**********************************************************************************************************************"
' f.WriteLine "**********************************************************************************************************************"
' f.WriteLine "**********************************************************************************************************************"
' f.WriteLine ""

'For Each Item in infItems
' f.WriteLine "Description: " & Item.Description
' f.WriteLine "Device Class: " & Item.DeviceClass
' f.WriteLine "Device ID: " & Item.DeviceID
' f.WriteLine "Device Name: " & Item.DeviceName
' f.WriteLine "Hardware ID: " & Item.HardwareID
' f.WriteLine "Inf Name: " & Item.InfName
' f.WriteLine ""
'Next
f.close
wscript.echo "Finished"
Comments
Liam_Finn1
Level 6
Employee Accredited Certified
 Very cool. Thanks for posting this
hparker
Not applicable
For anybody that may be looking for related scripts or utilties... Here are some from microsoft:
http://technet.microsoft.com/en-us/magazine/2006.05.utilityspotlight.aspx

There's also a tool available from sourceforge written by one of the MSFN forums regulars that does a related job, it's called FindHWIDs - it will find all the Hardware IDs in a given set of driver folders and record them to a CSV file for comparison with the output of scripts like the above ones.  The author has also written a "Driver Installer" tool called DriverForge that takes a folder (or folder tree) of drivers and installs all of them that apply to the current hardware.
http://sourceforge.net/projects/driverforge/

Hope that's what someone was looking for!
deepak_vasudeva
Level 6

Rather than directly tampering with

winmgmts:\\" & strComputer & "\root\cimv2 I would suggest working through a quick C# Code using System.Management.dll since that would be quick way to elegantly handle errors and exceptions.

EdT
Level 6

That's fine for those with C# programming experience, and the appropriate compiler installed on their system. The beauty of using a scripted solution is that there is no requirement for C# programming knowledge, no requirement for any specific version of .NET to be installed, and no requirement for anything more than a text editor to create the code.

yogeshsadhu
Not applicable
Employee

Its very useful.

Thanks

Version history
Last update:
‎08-03-2009 10:54 AM
Updated by: