Windows – How to delete non-existing printers in Windows

network-printerwindows 7wmi

A few network printers have been removed from the print server and I wish to automatically remove them by a script (e.g. using objPrinter.delete_ in vbs) from any client still referencing them; preferably, I would like to really know which printers I'm deleting in those cases and automatically connect an appropriate replacement printer. This would not be difficult if I could read the list of such defunct printers in the first place.

The situation in the GUI is that the printers still show up under "Devices and printers" with the printer symbol showing only the default printer icon,being greyed out, and a yellow warning triangle shown next to it. But the printer does not get listed e.g. by the WMI query "SELECT * FROM Win32_Printer". Is there any other query that would succeed for this?

Best Answer

To delete a network printer through the command-line and without GUI, is possible through updating the registry.

The following two registry keys contain installed printer definitions :

HKEY_CURRENT_USER\Printers\Connections
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Providers\LanMan Print Services\Servers\Printers

You need to find the names of the sub-keys of the above that contain the network printers you wish to delete. Once you know their names, this also becomes a method for checking if a certain printer is currently installed. Delete the sub-keys, then reboot to verify that the printer stays deleted.

There are certain important points here :

  1. The Print Spooler service may need to be stopped.
  2. The printer queue must be empty, found at the folder C:\Windows\System32\spool\PRINTERS\. You can't remove a printer if you have items in the print queue. See also the article How to Forcefully Clear the Print Queue in Windows.
  3. The GUI way to delete a printer is by running as Administrator printui /s /t2, select the printer, click Remove button, check "Remove driver and driver package" and click OK.

Some more details can be found in the article Fix for Cannot Remove or Delete Network Printer in Windows.

Related Question