on 08-03-2009 10:54 AM
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.
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"
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.
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.
Its very useful.
Thanks