Forum Home
Press F1
 
Thread ID: 86864 2008-01-30 21:25:00 vb script to remove all printers? mOOseCaNNoN (13319) Press F1
Post ID Timestamp Content User
635676 2008-01-30 21:25:00 Does anyone know how to remove all network printers on logon? reason being there are a lot of non existent printers in users printers and faxes. There are scripts to remove individual printers but you have to know the exact name/path of the printer in order to delete it, is there some sort of wild card i can use to delete all printers so i can then map fresh ones?

at the moment the logon script for printers looks like this

On Error Resume Next
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\office\OfficeLaser"
WshNetwork.AddWindowsPrinterConnection "\\oa1\Photocopier-Admin"
WshNetwork.AddWindowsPrinterConnection "\\oa1\Photocopier-J"
WshNetwork.AddWindowsPrinterConnection "\\SWR01\SWRLaser"


cheers
mOOseCaNNoN (13319)
635677 2008-01-30 22:29:00 nevermind, i found one online and edited it to suit.
if anyone's interested here's the code to remove all network printers.

On error resume next

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 0 to oPrinters.Count - 1 Step 2
WScript.Echo oPrinters.Item(i+1)
WshNetwork.RemovePrinterConnection oPrinters.Item(i+1)

Next
mOOseCaNNoN (13319)
1