Need to remove network printers but not mapped printers
- From: "Larry D" <larryd@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 14 Nov 2005 16:24:27 -0600
I am renaming my network printers and have tested this script and it removes
all network printers and leaves local printers alone:
ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER
+1),True,True
End If
Next
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
wscript.quit
Then I use this script to map a renamed printer such as CA - HP LaserJet
4050 PS near Purchasing on the \\printerserver:
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\printserver\CA - HP LaserJet 4050
PS near Purchasing"
The problem is the top script also removes mapped printers that are shared
between desktop PCs. How can I change the top script to remove only network
printers that are attached to \\printserver and not to \\desktopPC ?
Thanks for any help.
Larry
.
- Follow-Ups:
- Re: Need to remove network printers but not mapped printers
- From: Andrew Cushen
- Re: Need to remove network printers but not mapped printers
- Prev by Date: Re: WshShell.SendKeys(Keys, Wait)?
- Next by Date: Re: WshShell.SendKeys(Keys, Wait)?
- Previous by thread: Good Step by Step & Reference Book on WSH for beginners
- Next by thread: Re: Need to remove network printers but not mapped printers
- Index(es):
Relevant Pages
|
Loading