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

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 <Drive:>\Folder\ListPrinters.vbs

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

"ScanSoft PDF Create!",""
"HP Officejet 6200 series fax",""
"HP Officejet 6200 series",""
"Generic / Text Only",""
"File Print FedEx Kinko's","FedEx Kinko's"
"\\JSI001\HP Business Inkjet 2250 (PCL5C)","HDQ Printer Room"
If you wanted to process this list in a batch file, use:
for /f Token=1* Delims=," %%a in ('cscript //nologo <Drive:>\Folder\ListPrinters.vbs') do (
 set prt=%%a
 set loc=%%b
 . . . .
ListPrinters.vbs contains:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "\{impersonationLevel=impersonate\}!\\" & strComputer & "\root\cimv2")
Set iPrt =  objWMIService.ExecQuery ("Select * from Win32_Printer")
For Each objPrinter in iPrt
" &objPrinter.Name &
& objPrinter.Location &
" Next

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.