【问题标题】:How to get printer information using command line on Windows machine?如何在 Windows 机器上使用命令行获取打印机信息?
【发布时间】:2010-10-22 13:20:10
【问题描述】:

我需要使用命令行获取 Windows XP 打印机信息,例如打印机端口和驱动程序名称。

我尝试使用 Windows Server 2003 资源工具包工具为您提供此类信息,但它需要管理权限。在我们的生产场景中,我们也不能仅仅依靠部署一些外部工具包来获取打印机信息。

对此有什么想法吗?

【问题讨论】:

标签: windows-xp


【解决方案1】:
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery("Select * from Win32_PrinterConfiguration")
For Each objPrinter in colInstalledPrinters
    Wscript.Echo "Name: " & objPrinter.Name
    Wscript.Echo "Driver Version: " & objPrinter.DriverVersion
Next

【讨论】:

【解决方案2】:

您可以通过 VB 脚本使用 WMI 来实际获取信息,然后将其打印到控制台。在 cscript.exe 而不是 wscript.exe 中运行 VB 脚本会在控制台窗口中运行。

The ScriptingGuy article explains it a bit,但是还有很多关于 WMI 的可用信息

【讨论】:

  • 这是一篇非常好的文章!谢谢
【解决方案3】:

您也可以简单地转到 C:\Windows\System32 然后运行:

cscript prnmngr.vbs

从命令行...似乎可以为您提供所需的所有信息

http://technet.microsoft.com/en-us/library/cc725868(WS.10).aspx

【讨论】:

  • 在 Windows XP 上找不到 prnmngr.vbs!所以尝试 WMI SCript 选项,感谢您的帮助!
  • 从问题stackoverflow.com/questions/13311201/…,我发现位置现在是C:\Windows\System32\Printing_Admin_Scripts\en-US
猜你喜欢
  • 2010-09-22
  • 2021-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-19
  • 2013-07-30
相关资源
最近更新 更多