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.
我正在寻找一种方法来枚举工作站的本地Driverstore中的所有驱动程序,并检索“友好名称”,即用户看到的名称,例如添加打印机对话框。具体来说,我还想列出一类特定的设备,如打印机。
If possible vbscript or jscript via Windows Scripting Host. Alternatively parsing the output of a command line utility is fine too.
如果可能的话,通过Windows Scripting Host进行vbscript或jscript。或者,解析命令行实用程序的输出也很好。
1 个解决方案
#1
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 :)
我不是专家,但似乎只有拥有Microsoft Systems Management Server(SMS)才能编写此任务脚本。它提供了SMS_Driver WMI类,据我所知,它可用于查询驱动程序存储区中的驱动程序。下面的脚本应该让您了解如何做到这一点。 (免责声明:我没有短信,所以我不能证明这个脚本是正确的。谨防错误:)
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.
您可以在Root \ sms节点下的管理工具 - >计算机管理 - >服务和应用程序 - > WMI控制 - >属性 - >安全性中找到您的站点代码。
该脚本应该列出所有驱动程序类;如果您只需要特定的类(例如打印机驱动程序),则将查询更改为SELECT * FROM SMS \ _Driver WHERE DriverClass = _insert \ _proper \ _DriverClass \ _here_应该可以解决问题。
#1
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 :)
我不是专家,但似乎只有拥有Microsoft Systems Management Server(SMS)才能编写此任务脚本。它提供了SMS_Driver WMI类,据我所知,它可用于查询驱动程序存储区中的驱动程序。下面的脚本应该让您了解如何做到这一点。 (免责声明:我没有短信,所以我不能证明这个脚本是正确的。谨防错误:)
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.
您可以在Root \ sms节点下的管理工具 - >计算机管理 - >服务和应用程序 - > WMI控制 - >属性 - >安全性中找到您的站点代码。
该脚本应该列出所有驱动程序类;如果您只需要特定的类(例如打印机驱动程序),则将查询更改为SELECT * FROM SMS \ _Driver WHERE DriverClass = _insert \ _proper \ _DriverClass \ _here_应该可以解决问题。