Q. How can a script return all the printers and printer locations for a client?

Jerold Schulman

November 29, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

I have scripted ListPrinters.vbs to return all the printers and their locations that a client has access to.

The syntax for using ListPrinters.vbs is:

cscript //nologo FolderListPrinters.vbs

The console output is in CSV format. Here is a sample:

"ScanSoft PDF Create!","""NUL","""HP Officejet 6200 series fax","""HP Officejet 6200 series","""Generic / Text Only","""File Print FedEx Kinko's","FedEx Kinko's""\JSI001HP Business Inkjet 2250 (PCL5C)","HDQ Printer Room""\JSI001ZFax","Courier"

If you wanted to process this list in a batch file, use:

for /f Token=1* Delims=," %%a in ('cscript //nologo FolderListPrinters.vbs') do ( set prt=%%a set loc=%%b . . . .)

ListPrinters.vbs contains:

strComputer = "."Set objWMIService = GetObject("winmgmts:" _    & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")Set iPrt =  objWMIService.ExecQuery ("Select * from Win32_Printer")For Each objPrinter in iPrt    Wscript.Echo 

" &objPrinter.Name &

,

& objPrinter.Location &

"Next


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like