Link to home
Start Free TrialLog in
Avatar of Subnet_This
Subnet_ThisFlag for United States of America

asked on

VBS Script for Deleting Printers IF they Exist.

We're in the process of replacing new printers in my office. We currently have around 170 users, and I need a script that will run at login, to check for old printers and if one of the old printers exists, it is deleted.

We already have a login script to create the printers, which uses the "objNetwork.AddWindowsPrinterConnection" command. I just need one to run right before it, to delete the old printers.

Any ideas?

Thanks in advance!
Avatar of serialband
serialband
Flag of Ukraine image

From https://social.technet.microsoft.com/Forums/en-US/5141787d-9ac0-4e03-9b76-08de7db1530f/vbscript-to-delete-current-printers-and-add-new-printers

strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colInstalledPrinters =  objWMIService.ExecQuery _ ("Select * from Win32_Printer Where Network = TRUE") For Each objPrinter in colInstalledPrinters objPrinter.Delete_

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Robberbaron (robr)
Robberbaron (robr)
Flag of Australia 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