Search code examples
javascriptwindows-vistavbscriptdevice-driverwsh

Script to retrieve friendly names of all drivers in Windows Vista Driverstore


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.


Solution

  • 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.