Skip to content

Windows – Script to remove Printers including their drivers


Open CMD (no local Admin permissions needed!)
To remove the printer from a client enter the following command:
rundll32 printui.dll,PrintUIEntry /q /gd /dn /n\\Servername\Printername
To remove the driver from a client use the following command:
rundll32 printui.dll,PrintUIEntry /q /dd /m "Drivername"
Here you’ll find some information of the Technet article regarding this command:
Syntax
rundll32 printui.dll PrintUIEntry [BaseParameter] [ModificationParameter1] [ModificationParameter2] [ModificationParameterN]
You can also use the following alternate syntaxes, although the examples in this topic use the previous syntax:
rundll32 printui.dll,PrintUIEntry [BaseParameter] [ModificationParameter1] [ModificationParameter2] [ModificationParameterN]
rundll32 printui PrintUIEntry [BaseParameter] [ModificationParameter1] [ModificationParameter2] [ModificationParameterN]
rundll32 printui,PrintUIEntry [BaseParameter] [ModificationParameter1] [ModificationParameter2] [ModificationParameterN]
Parameters
There are two types of parameters: base parameters and modification parameters. Base parameters specify the function that the command is to perform. Only one of these parameters can appear in a given command line. Then, you can modify the base parameter by using one or more of the modification parameters if they are applicable to the base parameter (not all modification parameters are supported by all base parameters).
Base Parameters Description
/dl Deletes the local printer.
/dn Deletes a network printer connection.
/dd Deletes a printer driver.
/e Displays the printing preferences for a given printer.
/ga Adds a per computer printer connection (the connection is available to any user on that computer when they log on).
/ge Displays per computer printer connections on a computer.
/gd Deletes a per computer printer connection (the connection is deleted the next time a user logs on).
/ia Installs a printer driver by using an .inf file.
/id Installs a printer driver by using the Add Printer Driver Wizard.
/if Installs a printer by using an .inf file.
/ii Installs a printer by using the Add Printer wizard with an .inf file.
/il Installs a printer by using the Add Printer wizard.
/in Connects to a remote network printer.
/ip Installs a printer by using the Network Printer Installation Wizard (available from the user interface from Print Management).
/k Prints a test page on a printer.
/o Displays the queue for a printer.
Examples
To add a new remote printer, Printer1, for a computer, Client1, which is visible for the user account where this command is run, type:
rundll32 printui.dll PrintUIEntry /in /n\\client1\printer1
To add a printer using the Add Printer wizard and using an .inf file, InfFile.inf, located on drive c: at InfPath, type:
rundll32 printui.dll PrintUIEntry /ii /f c:\InfPath\InfFile.inf
To delete an existing printer, Printer1, on a computer, Client1, type:
rundll32 printui.dll PrintUIEntry /dn /n\\client1\printer1
To add a per computer printer connection, Printer2, for all users of a computer, Client2, type (the connection will be applied when a user logs on):
rundll32 printui.dll PrintUIEntry /ga /n\\client2\printer2
To delete a per computer printer connection, Printer2, for all users of a computer, Client2, type (the connection will be deleted when a user logs on):
rundll32 printui.dll PrintUIEntry /gd /n\\client2\printer2
To view the properties of the print server, PrintServer1, type:
rundll32 printui.dll PrintUIEntry /s /t1 /c\\printserver1
To view the properties of a printer, Printer3, type:
rundll32 printui.dll PrintUIEntry /p /n\\printer3
Reference: http://technet.microsoft.com/en-us/library/ee624057.aspx