Need simple printer script
- From: TCS <tsmithATeastpointcityORG>
- Date: Fri, 19 Dec 2008 10:10:05 -0800
I need to list, to a .csv file preferably, all the printers on my print
server. I'd like the printer name and the ip address. I believe this will
be sufficent for what I need.
When I search the net, I find script to install printers, which I don't want
to do. And I've found a script to Enumerate Printer Port Properties, which
will give me the address, but for the name, I need another script I found
that will List Printer Capabilities.
I THINK I could pull enough of what I need from each to get what I want, but
I don't know what ties them together. I mean, how do I get the same printer
for port 123, when I'm retreiving capabilities to get the name?
( The 'Description' property is always empty when I read thru the port
properties. )
Here's one script I found:
-----
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPorts = objWMIService.ExecQuery _
("Select * from Win32_TCPIPPrinterPort")
For Each objPort in colPorts
Wscript.Echo _
"Description...( " & objPort.Description & " )" & VbCrLf & _
"Host Address...( " & objPort.HostAddress & " )" & VbCrLf & _
"Name...( " & objPort.Name & " )" & VbCrLf & _
"Port Number...( " & objPort.PortNumber & " )" & VbCrLf & _
"Protocol...( " & objPort.Protocol & " )" & VbCrLf & _
"SNMP Community...( " & objPort.SNMPCommunity & " )" & VbCrLf & _
"SNMP Dev Index...( " & objPort.SnMPDevIndex & " )" & VbCrLf & _
"SNMP Enabled...( " & objPort.SNMPEnabled & " )"
Next
-----
And here's the other:
-----
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 "Collate: " & objPrinter.Collate
Wscript.Echo "Copies: " & objPrinter.Copies
Wscript.Echo "Driver Version: " & objPrinter.DriverVersion
Wscript.Echo "Duplex: " & objPrinter.Duplex
Wscript.Echo "Horizontal Resolution: " & _
objPrinter.HorizontalResolution
If objPrinter.Orientation = 1 Then
strOrientation = "Portrait"
Else
strOrientation = "Landscape"
End If
Wscript.Echo "Orientation : " & strOrientation
Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254
Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254
Wscript.Echo "Print Quality: " & objPrinter.PrintQuality
Wscript.Echo "Scale: " & objPrinter.Scale
Wscript.Echo "Specification Version: " & _
objPrinter.SpecificationVersion
If objPrinter.TTOption = 1 Then
strTTOption = "Print TrueType fonts as graphics."
Elseif objPrinter.TTOption = 2 Then
strTTOption = "Download TrueType fonts as soft fonts."
Else
strTTOption = "Substitute device fonts for TrueType fonts."
End If
Wscript.Echo "True Type Option: " & strTTOption
Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution
Next
-----
Like I said, I just want the printer name and the port.
Anyone know how I need to do it?
Thanks in advance,
Tom
.
- Prev by Date: Please help with vbs folder search and copy
- Next by Date: Need help with a logon script
- Previous by thread: Please help with vbs folder search and copy
- Next by thread: Need help with a logon script
- Index(es):
Relevant Pages
|