Permanently removing Windows printers that keeps coming back

A simple change: a new Windows print server requiring a change in the printers installed using a Group Policy Targeting GPO (refer to this post from 2015 for more details).

Not so easy. Removing the old/existing printers were all but impossible. Nothing worked. Nothing. Others have had similar experiences; e.g. here, here, and here.

This is a two part post: 1) the actual removal script and 2) other online resources and discussion around the issue.

Removal Script

This script was used as GPO Computer shutdown script.

  1. Download: permanently_remove_printers_COMPUTER_shutdown_script.zip
  2. Edit the “shutdown_registry_printer_purge.bat” batch file. Go to Line 19 and 20 and change the server name in quotes for both lines. Two lines per printer.
    REM ------------------------------> Add these two lines per printer to remove and change server name <------------------------------
    
    rundll32 printui.dll,PrintUIEntry /gd /q /n"\\print\PaperCut"
    rundll32 printui.dll,PrintUIEntry /dn /q /n"\\print\PaperCut"
  3. Go to Line 23 and change the server name in quotes. One line per printer.
    REM ------------------------------> Add this one line per printer to remove and change server name <------------------------------
    
    ADPRINTX.exe /r "\\print\PaperCut"
  4. Edit the “printer_hive_cleanup.vbs” file. Go to Line 117 and 119 and change the server name in quotes for both lines. Two lines per printer.

    A special thanks to Mick for his wonderful vbs script. If you want a less forceful method, Mick also references a way to do per-user registry edit using Active-Setup (I did not test this method).
  5. Add the .bat file to a shutdown or startup script.
    The script must run as the SYSTEM user.

Other Resources on adding/removing Windows printers

  1. Removing a printer device FULLY – Microsoft Community 
  2. group policy – Deleted printers keeps coming back – and multiply – Server Fault 
  3. Problem with multiple instances of shared printers being installed on client computers when the spooler service is started 
  4. [SOLVED] All network printers automatically added for each user on 2012 R2 RDSH – Microsoft Remote Desktop Services – Spiceworks 
  5. Remove Printers by Name or Server – Script Center – Spiceworks 
  6. script to add new network printers 
  7. Set Default Printer if not in a specific group – Petri IT Knowledgebase Forums 
  8. Adding a network printer from the command line (or bat file) – Networking – Spiceworks 
  9. Script to remove obsolete printer in local profiles – Petri
  10. Hey, Scripting Guy! How Can I Remove All the Network Printers on a Computer?
  11. Printer mapping using GPP 
  12. Intermittent printer delivery failures with GPP – XenDesktop 7.x – Discussions 
  13. Logon Script Example Assign Printer – RUNDLL32 PRINTUI.DLL 
  14. scripting – Need to modify VB script so it deletes all existing network printers first – Server Fault 
  15. Adding and deleting printer drivers on Windows from INF files via command-line | Hajuria’s Blog 
  16. KB3170455 preventing printer installation 
  17. command line – Trying to use rundll32 printui.dll, PrintUIEntry to set up a printer, getting an error – Super User 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.