PCright, Inc. | Recently... | Elsewhere | Search | Login |

This is the area where you can put a text about yourself or your blog. You can change the colours and the layout as you like, but please keep the footer link the way the way it is so that other can find the way back to me. Thanks for using this theme, I really appreciate it. This theme is released under those Creative Commons terms of use. And now ENJOY and get blogging!

continue reading this article


Setup Windows Printers from a batch file.

23 10 2009


I’ve got a little free time for a change, so why not write something vaguely useful.

I have been scripting printer installs successfully on XP, the release of Win 7 shouldn’t change that procedure (much).  7 still has most of the familiar admin scripts as XP. So we should still be able to setup printers through those same scripts instead of having to babysit each printer.  The basic idea is to obtain manufacturer’s drivers and get them unzipped onto the destination computer.  Then run scripts that are distributed with Windows (they live in C:\Windows\system32\).  The scripts can be called, in turn, from a simple batch file.

Some notes:

  • My installs all use Standard TCP/IP Printer ports.
  • Watch out for directory path slashes.  The scripts expect path names to be escaped.
  • Exact driver names (and they’re case sensitive) must be used.
  • Some drivers must be unzipped to a specific folder, others don’t care.
  • You’ll have to dig around in the printer driver install folder to find the correct hardware inf, and specify it’s full path and name.
  • cscript requires the full path to the admin script you are calling.
  • Unzip32.EXE came from http://www.info-zip.org/

Here’s a single printer batch example (it can be expanded for any number and types of printers):

#REM 1. Extract HP Universal PCL Driver
#REM This driver is touchy about its destination.  It must go in the specified directory
unzip32 -d “\HP PCL5 Universal Print Driver” “ljp2035pcl5 – HPUPD47PCL532.exe”

#REM 2. Install driver.

cscript.exe c:\WINDOWS\system32\prndrvr.vbs -a -m “HP Universal Printing PCL 5” -e “Windows NT X86” -h “c:\\HP PCL5 Universal Print Driver\\” -i “C:\\HP PCL5 Universal Print Driver\\hpcu083b.inf”

#REM 3. Setup Copy Room Printer Port
cscript.exe c:\windows\system32\prnport.vbs -a -r IP_192.168.70.11 -h -o raw -n 9100

#REM 4. Actual printer install

cscript.exe c:\windows\system32\prnmngr.vbs -a -p “LaserJet Copy Room” -r “IP_192.168.70.11” -m “HP Universal Printing PCL 5”

categories Published under: Technology

Leave a message or two

This post was written on the Friday, October 23rd, 2009 at 9:33 am and categorized under Technology. You can follow the ongoing discussion by subscribing to the RSS 2.0. You can leave a reply, or Trackback.

4 comments so far

  1. Phil wrote on 14. June 2012 at 5:25 pm o'clock                  

    Hello, this is exactly what I’ve been searching for, but I’m running into some trouble.
    When I try to run it, it just brings up the usage text as if something is wrong, but as far as I can tell it should be all OK.
    Below is the result I get for trying to run the script. Any suggestions?

    Usage: prndrvr [-adlx?] [-m model][-v version][-e environment][-
    [-u user name][-w password][-h path][-i inf file]
    -a – add the specified driver
    -d – delete the specified driver
    -e – environment “Windows {NT x86 | X64 | IA64}”
    -h – driver file path
    -i – fully qualified inf file name
    -l – list all drivers
    -m – driver model name
    -s – server name
    -u – user name
    -v – version
    -w – password
    -x – delete all drivers that are not in use
    -? – display command usage

  2. blackmenthol wrote on 06. September 2012 at 10:00 pm o'clock                  

    where is the vbs script that you used? (prndrvr.vbs, prnport.vbs, prnmngr.vbs)

  3. admin wrote on 26. November 2012 at 6:57 pm o'clock                  

    If they’re not there, check another PC and copy them over.

  4. admin wrote on 26. November 2012 at 6:58 pm o'clock                  

    Sorry for the long wait.
    Yes, you have to supply all of the command line options on one line, at the time of run. That’s the only way it works. No GUI. 🙁

Name (required)

Email (required)


XHTML: The following tags are allowed:

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please leave a comment