views:

401

answers:

1

I am seeking a way to enumerate all Drivers in the local Driverstore of the workstation and retrieve the "friendly name" that is the Name that the User sees in for instance the add printer dialog. Specifically i would also like to list only a specific class of devices like Printer.

If possible vbscript or jscript via Windows Scripting Host. Alternatively parsing the output of a command line utility is fine too.

A: 

I'm not an expert, but it seems that this task can be scripted only if you have Microsoft Systems Management Server (SMS). It provides the SMS_Driver WMI class that, as far as I understand it, can be used to query drivers in the Driver Store. The script below should give you the idea of how this can be done. (Disclaimer: I don't have SMS, so I can't prove this script correct. Beware of bugs :)

On Error Resume Next

strComputer = "."   ' Computer name. Dot means local computer

' Connect to the SMS Provider
Set oWMIService = GetObject("winmgmts:" & _
    "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sms\site_XXX") ' Replace XXX with your site code (see notes below)
If Err.Number <> 0 Then
    WScript.Echo "WBemServices connection failed. Error " & Err.Number & ": " & Err.Description
    WScript.Quit
End If

' Get all device drivers
Set colDrivers = oWMIService.ExecQuery("SELECT * FROM SMS_Driver")

' List properties of each driver
For Each objDriver In colDrivers
    WScript.Echo _
      "Name: "        & objDriver.LocalizedDisplayName & vbNewLine & _
      "Class: "       & objDriver.DriverClass          & vbNewLine & _
      "Model name: "  & objDriver.ModelName            & vbNewLine & _
      "Description: " & objDriver.LocalizedDescription & vbNewLine & _
      "Version: "     & objDriver.DriverVersion        & vbNewLine & _
      "Provider: "    & objDriver.DriverProvider       & vbNewLine & _
      "Path: "        & objDriver.ContentSourcePath    & vbNewLine & _
      "File: "        & objDriver.DriverINFFile        & vbNewLine
Next

Notes:

  • You can probably find your site code in Administrative Tools -> Computer Management -> Services and Applications -> WMI Control -> Properties -> Security, under the Root\sms node.
  • The script is supposed to list all driver classes; if you need only specific classes (e.g. printer drivers), changing the query to
    SELECT * FROM SMS_Driver WHERE DriverClass=insert_proper_DriverClass_here
    should do the trick.
Helen
That would be the ideal solution if we had SMS. So this is basically a good solution. It can not be directly applied to my issue however as i am specifically looking at the local driver store. I will update the question.
Dominique Vocat