If you don’t use a print server in your Windows environment (for which there are many valid reasons) then printer management can be a major frustration. We don’t use a print server, but rather create static printers with local TCP/IP ports.
Installing these one by one, or updating drivers had become a drain on time, so I set about finding out how to silently deploy them to our client PC’s.
You’ll need a few support files to get this deployment working. The first are 3 vbs scripts:
You can find these in C:\Windows\System32 on a Windows XP machine.
You’ll also need PSEXEC from here: http://technet.microsoft.com/en-us/sysinternals/bb897553
Place the VBS scripts on a network share, perhaps where you’ll be storing the deployment batch files.
Below is the contents of a single printer install batch file. You can also combine multiple printer commands into one file, so that all printers in one office would be deployed at once.
This batch file should be run from somewhere other than the client PC you’re deploying to. Make sure you have PSexec somewhere in the path on that machine.
::This Script installs the following: ## denotes commented out by default :: Printer Name :: If you do not wish a certain printer to be installed, make a copy of this file, comment out the specific printer, and run the file :: Define computer to push to, and the password to use for psexec authentication set computername=TestPC set password=pa55w0rd :: Printer1 :: :: Deletes previously installed printer of the specified name cscript "\\server\Deploy\prnmngr.vbs" -d -s %computername% -p "Old Printer" :: Deletes static port of previous printer, in case of mis-configuration cscript "\\server\Deploy\prnport.vbs" -d -s %computername% -r IP_192.168.0.42 :: Creates TCP/IP port with specified IP address cscript "\\server\Deploy\prnport.vbs" -a -s %computername% -r IP_192.168.0.28 -h 192.168.0.28 -o raw -n 9100 :: Copies driver for printer from server to local directory psexec \\%computername% -u domain\adminaccount -p %password% xcopy /E "\\server\Printer\HP 4500ps W2K-WXP\*.*" "c:\printdrv\" ::Install printer driver to computer from specified location. cscript "\\server\Deploy\prndrvr.vbs" -a -s %computername% -m "HP Designjet 4500ps HP-GL/2" -v 3 -e "Windows NT x86" -h "c:\printdrv" -i "c:\printdrv\dsgj4500.inf" :: Removes local directory containing print driver psexec \\%computername% -u domain\adminaccount -p %password% cmd.exe "/C rmdir /S /Q "c:\printdrv\"" :: Install the printer, using the print driver specified prior. cscript "\\server\Deploy\prnmngr.vbs" -a -s %computername% -p "Plotter3" -m "HP Designjet 4500ps HP-GL/2" -r IP_192.168.0.28 -u domain\adminaccount -w %password% :: Sets the Printer Properties according to a template created prior psexec \\%computername% -u domain\adminaccount -p %password% regedit.exe /s \\server\Deploy\Preferences\SurveyPrinter-WinXP.reg pause
If you’re deploying to Windows 7 x64, make sure you’re using x64 drivers, and then in the driver install section, change this: -e “Windows NT x86” to this: -e “Windows x64”
As shown in the last command, you can set printer properties (such as including a duplexer, stapler, additional paper trays) by installing the printer on a test machine, configuring the options you want, and then exporting this registry key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Printer Name\PrinterDriverData]
You can also modify Printer Preferences using the same method. The registry key to export there is:
If you’re doing this, you’ll want to remove the extra printers from that key, and it must be run by the user who needs the preferences. Because of that I haven’t found a way to deploy the Printer Preferences directly to a user. Instead I just distribute the .reg file for them to run.
HP Printer Drivers
Recent versions of the HP printer drivers have been having problems installing using the VBS script. Because of this, a different command is used to install them:
psexec \\%computername% -u domain\adminaccount -p %password% rundll32.exe printui.dll PrintUIEntry /ia /f c:\printdrv\hpcu109u.inf /m "HP Universal Printing PCL 6"