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