Link to home
Start Free TrialLog in
Avatar of DMS-X
DMS-X

asked on

VB script to delete multiple pritners

I need a script to delete multiple printers if they exist. The script below seems to work but only if the printer exists. If the printer doesnt exist then I get errors. I need some kind of "IF" statement so if the printer doesnt exist I dont get errors. How can I do this?
------code start------
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemovePrinterConnection "\\server\printer1"
WshNetwork.RemovePrinterConnection "\\server\printer2"
------code end-------

Thanks
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DMS-X
DMS-X

ASKER

Thanks