tags:

views:

24

answers:

3

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 too we cannot rely on some external toolkits to be deployed just to get the printer info.

Any ideas on this?

A: 

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

mdm
It was a very nice article! Thanks
Yani
+1  A: 
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
ghostdog74
Exactly what I was looking for but couldn't find - good stuff.
mdm
This is really close to what I wanted. But I needed the driver name as well. Here you go: http://www.computerperformance.co.uk/vbscript/wmi_printer.htm
Yani
A: 

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

AdamH
Could not find prnmngr.vbs on Windows XP! So trying the WMI SCript option, thanks for the help!
Yani