How to add a network (IP) printer using command line or a script?

12,684

I was getting the same error as you until I tried this:

cscript c:\Windows\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_192.168.1.5 -h 192.168.1.5 -o raw

The source "http://www.velocityreviews.com/forums/t514172-adding-printing-ports-and-printers-systematically-on-x64-windows-2003-r2.html" for the answer reads:

When the IP does not exist or not yet on the network, you will need to specify the protocol and LPR queue name for the device. If the device is not included in tcpmon.ini you may also need to pass in the device configuration to the script.

The results of this command that I got were:

Created/updated port IP_192.168.1.5

Share:
12,684

Related videos on Youtube

vrtigo1
Author by

vrtigo1

Updated on September 18, 2022

Comments

  • vrtigo1
    vrtigo1 almost 2 years

    My company will be deploying a bunch of laptops that will be used during a seminar for people to sign up for services on our website. At the end of the signup process they will need to print out a confirmation page.

    We have a deployment tool (KACE) that will load a fresh copy of Windows 7, set the IE home page to what it needs to be, etc and I am looking for a way to set up a network printer using the command line, a batch file or a script so we don't have to do the setup manually on every computer as that would take a long time.

    The printer is a Konica Minolta network copier and it needs to be set up as a local printer using a tcp/ip port.

    I've found a couple vbscript files that are supposed to do this but I inevitably get errors when I try to make them work for me.

    I have also tried to use prnport.vbs, but I can't even get past the first step of creating a tcp/ip port:

    cscript c:\Windows\System32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_192.168.1.5 -h 192.168.1.5
    

    returns:

    Unable to create/update port IP_192.168.1.5 Error 0x80041008 Invalid parameter
    

    I've tried using different port names but always get this error.

    Can someone help me figure out how to accomplish this?

    • root
      root over 10 years
      Cscript's Prnport.vbs is definitely what you want. Are you on a domain? It's possible that this is a permissions issue, in which case you would use the appropriate username/password values after the -u and -w flags respectfully.