User Tools

Site Tools


windows:install_printer_silently

This works both for Vista, 7 and 8. XP is not supported (who cares anyway at this point in time :P) Saves me a lot of time at work. I could use a printer server (and have done so in the past), but I am no fan of “single point of failure”.

Do the following to make the script work:

  1. Set a printer name (you choose)
  2. Set a printer model (has to be the exact model from the printer driver .inf file)
  3. Set an IP address (obviously the IP the printer has today)
  4. Set 'remote-box', aka. which machine the printer should be installed on. Can be a hostname, can be an IP address.
  5. Set driver-file, this is the location of the .inf file that specifies your printer driver
  6. Set the architecture. “Windows NT x86” = 32 bit, “Windows x64” = 64 bit.

Afterwards just sit back and enjoy and let the script do it's thing.

installprinter.bat
:: Printer-name example: DKTASA06
set PRINTER-NAME=DKTAMA01
 
:: Printer-model example: HP Color LaserJet 4730mfp PCL 6 (Found inside the .inf driver file)
set PRINTER-MODEL=HP Color LaserJet CP4005 PCL 6
 
:: Printer-ip example: 192.168.195.7
set PRINTER-IP=192.168.195.168
 
:: Remote-box example: DKPC123123123
set REMOTE-BOX=DKPC1106281327
 
:: Driver-file example: \\192.168.223.50\open\Local\Printere\Hp - Color Laserjet 4730mfp Pcl 6\hpc4730c.inf
set DRIVER-FILE=\\192.168.223.50\open\Local\Printere\HP_CLJ_CP4005_64bit_XP_S2003_PCL6_HPDIU\Driver\hpc4005u.inf
 
:: Driver-arch example: Windows NT x86
set DRIVER-ARCH=Windows x64
 
:: Deletes previously installed printer of the specified name
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -s %REMOTE-BOX% -p "%PRINTER-NAME%"
 
:: Deletes previously installed printer of the specified name
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -d -s %REMOTE-BOX% -p "P-DKTAMA01"
 
:: Deletes static port of previous printer, in case of mis-configuration
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs" -d -s %REMOTE-BOX% -r IP_%PRINTER-IP%
 
:: Creates TCP/IP port with specified IP address
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnport.vbs" -a -s %REMOTE-BOX% -r IP_%PRINTER-IP% -h %PRINTER-IP% -o raw -n 9100
 
::Install printer driver to computer from specified location.
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs" -a -s %REMOTE-BOX% -m "%PRINTER-MODEL%" -v 3 -e "%DRIVER-ARCH%" -h "c:\printdrv" -i "%DRIVER-FILE%"
 
:: Install the printer, using the print driver specified prior.
cscript "%WINDIR%\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs" -a -s %REMOTE-BOX% -p "%PRINTER-NAME%" -m "%PRINTER-MODEL%" -r IP_%PRINTER-IP%
 
pause

Obviously you can optimize and automate a lot more in this script. If you do, please send me the changes! :)

windows/install_printer_silently.txt · Last modified: 2015/08/15 22:56 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki