用于检索 Windows Vista Driverstore 中所有驱动程序的友好名称的脚本

发布于 2024-07-23 01:14:01 字数 185 浏览 5 评论 0原文

我正在寻找一种方法来枚举工作站的本地驱动程序存储中的所有驱动程序,并检索“友好名称”,即用户在添加打印机对话框等中看到的名称。 具体来说,我还想仅列出特定类别的设备,例如打印机。

如果可能的话,通过 Windows Scripting Host 使用 vbscript 或 jscript。 或者解析命令行实用程序的输出也很好。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁梦 2024-07-30 01:14:01

我不是专家,但似乎只有当您拥有 Microsoft 系统时才能编写此任务的脚本管理服务器 (SMS)。 它提供了 SMS_Driver WMI 类,据我所知,可用于查询Driver Store中的驱动程序。 下面的脚本应该让您了解如何完成此操作。 (免责声明:我没有短信,所以我无法证明这个脚本是正确的。谨防错误:)

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

注意:

  • 您可能可以在管理工具 -> 中找到您的站点代码。 计算机管理-> 服务和应用 -> WMI 控制 -> 属性-> 安全性,位于 Root\sms 节点下。
  • 该脚本应该列出所有驱动程序类; 如果您只需要特定的类(例如打印机驱动程序),请将查询更改为
    从 SMS\_Driver 中选择 *,其中 DriverClass=_insert\_proper\_DriverClass\_here_

    应该可以解决问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文