removeprinters.vbs script not working

By mancini_me ·
Setup a new print server and would like to remove all old printers (w/ref to old print server) from all users roaming profiles. We have used this script in the past:

'Remove ALL old printers
'Enumerate all printers first, after that you can select the printers you want by performing some string checks
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'To remove only networked printers use this If Statement
If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
End If
'To remove all printers incuding LOCAL printers use this statement and comment out the If Statement above
'WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True

...but for some reason it is now working correctly now and throwing out the following error message:

Line 8
This network connection does not exist.
Code: 800708CA
Source: WSHNetwork.RemoveNetworkDrive

Any help?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums