Re: Enumerating Network Printers

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Feb 8, 6:44 am, Minja <Mi...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hello,
I would like to retreive a value of "Comment" field of network printers
installed on host machine using a Visual Basic Script.
Is it possible?

Thanks
Minja

From the MS Technet Script Center's Examples (slightly adapted and
with a little help from their scriptomatic.hta utility):

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root
\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
s = s & "Name: " & objPrinter.Name & ", "
s = s & "Location: " & objPrinter.Location & ", "
s = s & "Default: " & objPrinter.Default & ", "
s = s & "Comment: " & objPrinter.Comment & vbCRLF
Next
wsh.echo s

TechNet Script Center Sample Scripts (URL all one line)
http://www.microsoft.com/downloads/details.aspx?FamilyID=b4cb2678-dafb-4e30-b2da-b8814fe2da5a

Scriptomatic 2.0
http://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
.



Relevant Pages

  • Re: PrinterConnection Custom Script
    ... I created a script for all client in a customer. ... Set colInstalledPrinters = objWMIService.ExecQuery _ ... This script not runs in Windows 2000 clients. ...
    (microsoft.public.scripting.vbscript)
  • Re: Unsharing a printer
    ... should do the trick ... Set colInstalledPrinters = objWMIService.ExecQuery("Select Name from ... I am using the Echo statements for testing purpose... ... removed when the script is placed in the directory. ...
    (microsoft.public.scripting.wsh)
  • Change Printer Spooling Attribute with WMI
    ... I am trying to change the printer spooling attribute with WMI, ... Below is the script that I am running ... Set colInstalledPrinters = objWMIService.ExecQuery _ ...
    (microsoft.public.win32.programmer.wmi)
  • Re: PrinterConnection Custom Script
    ... "Tom Lavedas" wrote: ... I created a script for all client in a customer. ... Set colInstalledPrinters = objWMIService.ExecQuery _ ... This script not runs in Windows 2000 clients. ...
    (microsoft.public.scripting.vbscript)
  • Re: Printer Watermarks
    ... Here is a script that gets printer info on a computer. ... Set colInstalledPrinters = objWMIService.ExecQuery _ ... For Each objPrinter in colInstalledPrinters ... I also found a sample script that is supposed to delete printers. ...
    (microsoft.public.scripting.vbscript)