0
votes

I have about 200 identical make/model local printers installed throughout a building. The problem is that the default installation puts two drivers on the client, but sets the wrong driver as default. To change it manually, I right-click on the printer, choose "Printer Properties", click the "Advanced" tab and change the driver selection and click OK.

I need to do this on all the others, but hopefully not by having to manually visit each machine. I've looked at a bunch of WMI scripts, and examples using PrintUI.exe (printui.dll). I can change the driver selection using the following printui syntax:

printui /Xs /n "hp LaserJet 8888 PCL 5" DriverName "hp LaserJet 8890 PCL 5"

And this seems to work. But, the problem is that once I've run this command, the very next time I right-click on the printer and select "Printer Properties" I am prompted to re-install the printer driver using the wizard. Is there a better way or a way around this?

2

2 Answers

1
votes

late, but maybe can help... if you are using .inf file.

>>>> To do this without any wizard, the driver must be signed.

Windows 7:

INSTALLATION:

  • First Command install: RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Printer name" /f "driver.inf" /r "com1" /m "driver model name" /h "Intel"
  • Second Command set default printer: RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Printer name"
  • For installation you need just one command. Can change the "com1" if you are using usb, chose the most commom "usb001".

UNINSTALL:

To uninstall a printer you need 3 commands and strict follow the sequence:

  1. The first, you need to remove all printers with that name that you can see in "device and printers": RUNDLL32 PRINTUI.DLL,PrintUIEntry /dl /n "Printer Name" /h "Intel"
  2. The second command is to remove the printer driver: RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /m "driver model name" /h "Intel" . After this you cannot see the printer and the driver, but if you unplug the usb devide and plug again the driver will automatically install. this because windows add the driver installation pack to C:\Windows\System32\DriverStore\FileRepository and we need to uninstall it with the third command.
  3. The third command will remove the oem*.inf that is create by windows when install a driver. To complete this task you need 2 commands, the first is to search what the name of oem*.inf the windows creted for you: use this pnputil.exe -e to show all oem*.inf and with the name in hands use this pnputil.exe -f -d oem5.inf (change the name of the oem5.inf to correspond to you inf file)

I did thoses taks programmatically using this commands, except to search the oem*.inf name that you need to parse all .inf files under C:\Windows\Inf\.

There is a behavour that you need care when using cli to install... do not execute two installation for the same printer, windows will create a random name like you install printer B and windows will rename to printer B (copy_A) or something else if the printer B already exist. And if you need to uninstall you will need to remove the two printers before going to the second command to uninstall the driver.

Sometimes is better to uninstall all and install again.

Also see the code about devcon: https://code.msdn.microsoft.com/windowshardware/DevCon-Sample-4e95d71c

And details about the commands: http://www.robvanderwoude.com/2kprintcontrol.php

0
votes

I tried your command line on Windows XP and it worked for me without popping up any Printer Wizard. I used two drivers that were part of the XP OS itself. This is what I used -

rundll32 printui.dll PrintUIEntry /Xs /n "HP Color LaserJet 4550 PCL" DriverName "HP C LaserJet 4500-PS"

Maybe you may want to check it out again. Probably Win7 has some extra stuff which PrintUI is not doing right?

However, one word of caution. When you switch the drivers on the queue in this way, you lose the settings of the old queue. If this is ok, then going this path would be fine.

Now if you only want to change the default print queue on each client you should use this command-line - Say for setting "HP Color LaserJet 4550 PCL" as the queue you use -

rundll32 printui.dll,PrintUIEntry /y /n "HP Color LaserJet 4550 PCL"

Let me know if this helps