Translator

UserOnline

, 8 Guests, 4 Bots

Archives

Print This Post Print This Post

Installing printers using Prnmngr.vbs

 

I recently ran into a problem with the need to install network printers on quit a few non domain computers.  Then the need to stream line this process and make it easier for everyone to do I went back to using the printer vbscripts that were part of XP.  For the people that have never used Prnmngr.vbs and the other scripts that are part of the package, they do a really good job of install drivers, creating printers, and deleting the same printers.  The files needed are part Windows XP in the c:\Windows\System32 directory.

File list:

  1. Prnmngr.vbs
  2. Prnjobs.vbs
  3. Prndrvr.vbs
  4. Prnport.vbs
  5. Prncnfg.vbs
  6. Prnqctl.vbs

So with these files I pulled out a script I had written a few years ago and put it to use.  The biggest problem is getting the right drivers for the printer, not just one but this script was to have all of the printers that we would possibly install on these computers.  So after some modification and playing around this is what I came up with.  A simple menu based batch file that can be used to install printers.  Here is what it looks like.

@echo off
cls
echo =======================================================================
echo                                                                    PRINTER INSTALLATION
ECHO =======================================================================
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
set /p _ip=Enter printer IP:
cls
echo =======================================================================
echo                                                                     SELECT PRINTER TYPE
ECHO =======================================================================
echo.
echo.
echo.
echo              1.  Dell 1720.
echo              2.  Phaser 3600.
echo              3.  HP 4600
echo              4.  HP 2055
echo.
echo              x.  Exit
echo.
set /p _sel=Enter number:
if “%_sel%” == “1″ call goto d1720
if “%_sel%” == “2″ call goto Phaser
if “%_sel%” == “3″ call goto hp4600
if “%_sel%” == “4″ call goto hp2055
if “%_sel%’ == “x” call goto en
exit
: d1720
cscript Prndrvr.vbs -a -m “Dell Laser Printer 1720″ -v 3 -e “Windows NT x86″ -i “%CD%”\dell1720\DKABJ740.inf
cscript prnport.vbs -a -r IP_”%_ip%” -h “%_ip%” -o RAW -n 9100
cscript prnmngr.vbs -a -p “Dell 1720″ -m “Dell Laser Printer 1720″ -r IP_”%_ip%”
pause
cscript prnmngr.vbs -t -p “Dell 1720″
exit
: Phaser
cscript Prndrvr.vbs -a -m “Xerox Phaser 3600 PCL 6″ -v 3 -e “Windows NT x86″ -i “%CD%”\phaser3600\sxk2m.inf
cscript prnport.vbs -a -r IP_”%_ip%” -h “%_ip%” -o RAW -n 9100
cscript prnmngr.vbs -a -p “Phaser 3600″ -m “Xerox Phaser 3600 PCL 6″ -r IP_”%_ip%”
pause
cscript prnmngr.vbs -t -p “Phaser 3600″
exit
:hp4600
cscript Prndrvr.vbs -a -m “HP Color LaserJet 4600 PCL 5c” -v 3 -e “Windows NT x86″ -i “%CD%”\hp4600\PCL5c\hp4600p5.inf
cscript prnport.vbs -a -r IP_”%_ip%” -h “%_ip%” -o RAW -n 9100
cscript prnmngr.vbs -a -p “HP Laserjet 4600″ -m “HP Color LaserJet 4600 PCL 5c” -r IP_”%_ip%”
pause
cscript prnmngr.vbs -t -p “HP Laserjet 4600″
exit
:hp2055
cscript Prndrvr.vbs -a -m “HP LaserJet P2050 Series PCL6″ -v 3 -e “Windows NT x86″ -i “%CD%”\HP_P2055\hppcp613.inf
cscript prnport.vbs -a -r IP_”%_ip%” -h “%_ip%” -o RAW -n 9100
cscript prnmngr.vbs -a -p “HP 2055″ -m “HP LaserJet P2050 Series PCL6″ -r IP_”%_ip%”
pause
cscript prnmngr.vbs -t -p “HP 2055″
exit
:en
exit

To get the installation to work correctly you have to have the driver name as it shows up in the printer install dialog.  This is pretty easy to find you can try to install a fake printer on a system or you can look in the driver inf file to see what it is called.  First let me explain the script,  the basic syntax is straight forward.  By that I mean the echos, pause, and other basic commands.  The group of printer commands that run the vbs scripts are what I will cover.  The Prndrvr.vbs will simply install the driver before you create the printer, here is the syntax for the vbs file:

prndrvr {-a | -d | -l | -x | -?} [-m <model>] [-v {0|1|2|3}] [-e <environment>] [-s <ServerName>] [-u <UserName>]
[-w <Password>][-h <path>] [-i <inf file>]

prnport.vbs -a -r PortName [-s RemoteComputer] -h IPAddress [-u UserName -w Password]
[-o {raw -n PortNumber | lpr}] [-q QueueName] [-m{e | d}] [-i IndexName] [-y CommunityName] [-2{e | d}]

prnmngr.vbs -a -p PrinterName [-s RemoteComputer] -m DriverName -r PortName [-u UserName -w Password]

These are just what I used to make this work. You can do more than what I did here. I also wrote a script that would check
remote computers for the the printers that are installed. It would write back to the server and append a file. Anyhow this is
something else.

This printers script asks for the IP of the printer then you select the printer to install, then it installs the driver, creates
the printer port, and creates the printer. I did have to do some playing around with drivers, due to different OS versions and
32 vs 64 bit drivers. But a little work and I can pop in the cd, open an admin command window and install printers. I should
also add that our users can’t install their would printers due to security.

There is a number of ways to work with printers. I just wanted to throw out what I have been doing and you can even do this
over a network. I read about these is an admin book and they work well. I have also used these scripts on Windows 7 and they
worked. So if this will work for you check it out and there is more functionality than the little bit that I used it for.

 

UPDATE

These scripts can be found in Windows 7 at :  C:\Windows\System32\Printing_Admin_Scripts\en-US

8 comments to Installing printers using Prnmngr.vbs

  • avatar URL

    … [Trackback]

    [...] There you will find 69028 more Infos: blog.ogwatermelon.com/?p=3489 [...]

  • avatar URL

    … [Trackback]…

    [...] There you will find 69022 more Infos: blog.ogwatermelon.com/?p=3489 [...]…

  • avatar ogwatermelon

    I was having a problem with getting this to work on two different OSs. The first was Vista and everything worked great. All of the 8 printers I had built into the disk installed fine. Then I used it on a few old XP machines we still keep around and 3 of the printers would not install. They would come up with an error code 2. After some research I found that code 87 and code 2 are the same thing just thrown at different times. They both mean the script can’t find the driver. I had to play with the path and name of the folder to get theses drivers to install correctly. FYI.

  • avatar komplikator

    I just tried this, and also got Error Code 87.

    This means “invalid parameter”. However, this could also mean invalid filename. I had a CNLR0K.INF file in “-i” parameter, but I didn’t copy/paste it’s name, but mistakenly wrote CNLROK.INF. This gave the error code 87. Make sure everything is spelled ok.

    Now I have “Added printer driver Canon iR3025 UFR II” message! big grin

    Works like a charm!

  • avatar Brent

    That’s pretty cool. Don’t know that I have a use for it right now, but maybe sometime. Nice to know. Thanks.

  • avatar ogwatermelon

    I will play around with it and see if I can get it to work. What OS are you using this on? If the OS is not XP you will need the Prnmngr.vbs files from an XP install. I have used them on Windows 7, they are just not part of the OS anymore.

  • avatar AntonioGNAL

    Hello,
    Your script is really helping me, this is exactly what i need. But i’m getting an error with this line:

    cscript Prndrvr.vbs -a -m “HP Universal Printing PCL 5 (v5.3)” -v 3 -e “Windows NT x86″ -i “C:\Archivos de programa\PrintDrivers\HP\UPD\53110527\WS2003x32\PCL5\hpbuio20l.inf”

    Could you help me?

    Thanks!!!!

  • avatar AntonioGNAL

    Hello!
    This script is really helpful, but i’m still unable to make it work. There’s something i’m missing, could you help me?

    @echo off
    echo =======================================================================
    echo PRINTER INSTALLATION
    echo =======================================================================
    echo.
    echo.
    set /p _ip=Enter printer IP:
    cls
    echo =======================================================================
    echo SELECT PRINTER TYPE
    ECHO =======================================================================
    echo.
    echo 1. HP UPD Queue.
    echo.
    echo x. Exit
    echo.
    set /p _sel=Enter number:
    if “%_sel%” == “1″ call goto HPUPD
    if “%_sel%” == “x” call goto END
    exit
    :HPUPD
    cd c:\WINDOWS\System32
    cscript Prndrvr.vbs -a -m “HP Universal Printing PCL 5 (v5.3)” -v 3 -e “Windows NT x86″ -i “C:\Archivos de programa\PrintDrivers\HP\UPD\53110527\WS2003x32\PCL5\hpbuio20l.inf”
    pause
    cscript prnport.vbs -a -r IP_”%_ip%” -h “%_ip%” -o RAW -n 9100
    pause
    cscript prnmngr.vbs -a -p “HPUPD” -m “HP Universal Printing PCL 5″ -r IP_”%_ip%”
    pause
    cscript prnmngr.vbs -t -p “HPUPD”
    exit
    :END
    exit

    I’m getting an error saying the print driver is not installed. Win32 Error Code 87.

    Thanks!!!!