How to get printer information using command line on Windows machine?
I need to get Windows XP printer information like printer port and driver name using command line.
I tried using Windows Server 2003 Resource Kit Tools that give you such information but it needs administrative privileges. In our production scenario to开发者_如何学Pythono we cannot rely on some external toolkits to be deployed just to get the printer info.
Any ideas on this?
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
You could use WMI via a VB script to actually get the information, and then print it to the console. Running your VB script in cscript.exe rather than wscript.exe would run it in a console window.
The ScriptingGuy article explains it a bit, but there is plenty more info about WMI available
You can also simply go to C:\Windows\System32 and then run:
cscript prnmngr.vbs
From the command line... seems to give you all of the info you need
http://technet.microsoft.com/en-us/library/cc725868(WS.10).aspx
精彩评论