Script to delete print driver and printer connection

I recently had to delete a print driver and a printer connection for a large group of computers. I discovered that scripts for exactly that are already is avaliable in windows.

Delete a printer connection:

To delete a printer connection you can use the script called prnmngr.vbs

Delete a print driver:

To delete a print driver you can use the script called prndrvr.vbs

Where can the scripts be found ?

The folder where the tools can be found varies depending on the operating system.

Windows XP:

%windir%\system32\

Windows 7:

%windir\system32\Printing_Admin_Scripts\\

Examples:

To delete a printer connection from the local computer “Printers and Faxes” called Printer1 you use the following command line.

cscript.exe c:\windows\system32\prnmngr.vbs -d -p “Printer1”

To delete a print driver from the local computer you can use the follwing command line. This assumes you are running Windows XP and that the driver name is “Lexmark T654”.

cscript.exe c:\windows\system32\prndrvr.vbs -d -m “Lexmark T654” -v 3 -e “Windows NT x86”.

To run these scripts you need to be part of the local admin group or alternatively run the scripts as one who is member. This can be supplied as part of the command line.

Full documentation:

prnmngr.vbs:  http://technet.microsoft.com/en-us/library/cc725868

prndrvr.vbs: http://technet.microsoft.com/en-us/library/cc754632