Remove all Network Printers using VBScript
To delete a network printer using a login script you can use the following vb code. Just copy and paste the text into a new file called DeleteNetworkPrinters.vbs and call it from within your login script.
This will not delete any local printers installed to the machine. This is really useful to put in before you start mapping network printers during user logon.
‘————————————————————————-
‘– Removes all network printers but not any local 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_
Next
‘————————————————————————-
I’ve tested this code on Windows XP and Windows 7 and it works fine. I’m going to assume this is working on Windows Vista as well.