Tom
Fri Mar 07 07:06:39 CST 2008
On Mar 7, 5:52 am, "ThatsIT.net.au" <me@work> wrote:
> "gorahilly" <gorahi...@discussions.microsoft.com> wrote in message
>
> news:69F4DEFC-D2B3-4F34-8F92-F42EC0190420@microsoft.com...
>
> >I am using the script to delete all network printers installed on a
> > workstation.
> > Is there a way to specify to delete on the printers on a specific printer
> > server?
> > For example:
> > \\prntsrvr1\printer1
> > \\prntsrvr2\printer2
>
> > Is there a way to say delete all printers pointing to prntsrvr2?
>
> Yes simply use a if statment to test
>
> set objNetwork = CreateObject("wscript.network")
> Set objPrinters = objNetwork.EnumPrinterConnections
> For i = 0 to objPrinters.Count - 1 Step 2
> PrinterPath = objPrinters.Item(i+1)
> if PrinterPath = \\prntsrvr1\printer1 then
> objNetwork.RemovePrinterConnection PrinterPath, true, true
> end if
> Next
If there are multiple printers supported by a single print server as
implied by the OPs question, I think this slightly altered approach
that searches the PrinterPath might serve better (plus, there are a
couple of missing quotes in the example code above) ...
if Instr(lcase(PrinterPath), "prntsrvr1") > 0 then
objNetwork.RemovePrinterConnection PrinterPath, true, true
end if
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/