VBS Clean Printer list
If your looking to delete all the printers via script this is your code.
You can change the SELECT to pick certain printers.
You can change the SELECT to pick certain printers.
This .vbs can be deployed using GPO as a user login script.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * From Win32_Printer Where ServerName = '\\\\servername'",,48) For Each objPrinter in colInstalledPrinters objPrinter.Delete_ Next
All Printers
("SELECT * FROM Win32_Printer")
All printers where they are offline
("SELECT * FROM Win32_Printer WHERE ExtendedPrinterStatus = 2")
For more select statements please compile them using the information below.
http://msdn.microsoft.com/en-gb/library/windows/desktop/aa394363(v=vs.85).aspx
http://www.scriptinternals.com/new/us/support/Internal/WMI_Win32_Printer.htm
or search for “WMI Win32_Printer class”
Another useful tool is WMI Code Creator.
This will show you the values of current WMI records and build your select.