Quietly install a network printer – per user
rundll32 printui.dll,PrintUIEntry /q /in /n "\\machine\printer"
Quietly delete a named network printer – per user
rundll32 printui.dll,PrintUIEntry /q /dn /n "\\machine\printer"
Set default printer
rundll32 printui.dll,PrintUIEntry /y /n "\\machine\printer"
Quietly install a network printer – per machine
rundll32 printui.dll PrintUIEntry /q /ga /n "\\machine\printer"
Quietly delete a network printer – per machine
rundll32 printui.dll PrintUIEntry /q /gd /n "\\machine\printer"
Quietly delete a specific printer driver
rundll32 printui.dll,PrintUIEntry /q /dd /m "PrinterDriver"
From Windows 7 on, Microsoft has thoughtfully provided us with VBS scripts for command-line printer management, here:
In this neck of the woods, we go here to see them all, there are several:
To delete printer named ASDF:
cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -d -p "ASDF"
If you get “permission denied” trying to delete printers, delete everything relevant in all of these places (leaving the folders of course):
restart the spooler, refresh the Devices and Printers window, and you may be done, the involved printers will probably vanish. If they don’t they will be deletable at this point. If there are multiple user profiles on the PC, you will have to delete them in the other profiles. On some machines, some of the folders won’t exist, and this is perfectly fine.
- Change the Port, to “FILE:”, and then try to delete it again. If that doesn’t work:
- Go to this registry location:
and delete the ones that you want gone. Then restart the Windows service named ‘spooler’.
Here is a simple procedure for CMD, it works as long as the queue location was not changed:
net stop spooler
del /F /Q %systemroot%\System32\spool\PRINTERS\*
net start spooler
Remove old obsolete printer connections here:
HKEY_USERS\<the user's SID>\Printers\Connections
HKEY_USERS\<the user's SID>\Printers\Settings
and the problem goes away.
New versions of the HP Universal Printer Drivers are actually working well for such difficult situations as an older USB laser printer shared from an XP box to Windows 7 ×64. Here are elements:
- The HP web page for your printer, may list only HPU PCL 5 or PCL 6. That’s the version you will need to have.
- Copy the appropriate downloadable to both the host PC and the client PC. If the host is 32-bit and the guest is 64-bit, put the 32-bit downloadable on the host and the 64-bit downloadable on the guest. If different, do accordingly :-)
- Do NOT run the downloadable. Install 7zip or equivalent, and unpack to a folder.
- Make sure simple file sharing is off, and make sure both host and client have identical logins set up if this is not a domain network.
- If you are running a non-universal driver on the host, you can keep it if you want; but you do need to install an instance (or a second instance) of the printer using the appropriate HP Universal driver. Use the Windows printer add dialogue, not the HP Universal’s application. Share it to the network.
- On the client, again unpack, don’t run the downloadable.
- Don’t use the printer add dialogue on the client! Browse to the host, e.g., by putting “\\HOSTNAME” in the Explorer address area. Your printer will be visible. Right-click on it and choose “Connect”. If you chose to keep an original non-HP-Universal driver object, there will be two printer objects, and be sure to pick the right one!
- Eventually Windows will ask you for a driver if it needs one. Browse to the location at which you have unpacked the appropriate HP Universal driver, and tell it to go.
Sometimes, especially in Vista and 7, printer driver objects just won’t go away. Here is a tool which can make that happen: