PDA

View Full Version : Adding network Printers using a Batch file


Mistery1
Aug 19, 2009, 08:04 AM
Hi there,

Im hoping this is in the correct category.

I have created a batch file to add network printers to many computers, this is the example

@echo off

Cd c:\windows\system32
Cscript prnport.vbs -a -r IP_192.168.2.56 -h 192.168.2.56
Cscript prnmngr.vbs -a -p "Printer1" -m "Panasonic DP-4182" -r "IP_192.168.2.56"

It runs perfectly, BUT I have a problem if this port(Recommended printer port) does not exist on the machine it will not install the printer.

Any idea how to create a batch file that does this. Basically I need a batch file/ or a asp.net/VB code to install a printer on many machines WITH or WITHOUT the ports being available.

Hope this makes sense. Please can someone help.

chuckhole
Aug 19, 2009, 10:28 AM
You may be running into permissions issues. Since this is being performed on the local computer, it is done under the permissions of the logged on user. If the user does not have Administrator level permissions on the computer, they can not install the printer port or the drivers. Power Users will not have the required level of permissions.

You can perform this installation remotely using what you are already doing but by adding the correct switches to the VBScript.

Cscript.exe prnport.vbs -a -r PortName -s ComputerName -h IPAddress -q QueueName

Refer to this MS TechNet (http://technet.microsoft.com/en-us/library/cc772687(WS.10).aspx) article for more information on PrnPort.vbs

By doing this remotely, you are performing this using the permissions of your account (which I assume is a Domain Administrator). It is much easier to use a Windows Server for your printers and install the printers as shared devices. The users will only need Power User permissions on their PC's to add the printers and the drivers are centrally managed at the print server for all users.

A good link for scripting is the Microsoft Scripting Guys (http://technet.microsoft.com/en-us/scriptcenter/default.aspx).

Mistery1
Aug 19, 2009, 11:17 PM
Hi there,

Thanks for the reply.

I don't think this has anything to do with permissions because all the machines I have tested so far are domain administrators and they all have the required privileges.

I don't want to use this batch file remotely. Its just that I'm creating this to make our IT guys lives easier where they just click the bat file and the printers are installed ON NEW MACHINES instead of using the wizard which is also time consuming.

How I picked up that this code does not install the printers when the ports does not exist is that when the bat file runs it hangs if the port is not there and after a while its says port is unknown, which makes sense because I looked to that specific port, it does not exist on the machine. When I add the port in via the wizard and then run the bat file, it runs perfectly.

Any ideas on this. Someone please help on this one.

Thanks in advance.

Mistery1
Aug 20, 2009, 02:46 AM
Thanks for your help I have the answer. You have to add parameters. Check this link out

http://forums.techarena.in/xp-print-fax/449346.htm

chuckhole
Aug 20, 2009, 12:00 PM
Thanks for your help i have the answer. You have to add parameters. check this link out

Adding a printer/port Commandline - Auto installing printers/portd - XP Print Fax (http://forums.techarena.in/xp-print-fax/449346.htm)

The link I added for the TechNet article describes the use of the PrnPort.vbs file. The Port Name and the IP address of the port are two different things, and as you have discovered, must both be used. Using the remote machine name is the only part of the command line that mentioned in the post above is optional. You are not using LPR printing, so you do not have to specify the port type.

If your infrastrucuture is large enough, why not use a print server instead of installing TCP/IP ports and drivers on each PC? This is good discussion material.