Add Standard TCP/IP Printer

Posted on 2006-05-05
Last Modified: 2012-08-31
I would like to add networked printers using a Standard TCP/IP Printer port remotly to group of Workstations on my network. This printer should be available to any users that log onto the WS. Is there a script or GPO that could do this?

I would like to this so not to use a print server and have the printers mounted automatically w/o user interaction.

I am running a W2K03 Sever AD domain w/ WXP clients.
Question by:willtomaz808
    LVL 7

    Expert Comment

    You can use WMI scripting...

    Save this to file with a VBS extension then on your command prompt

    type in c:\Cscript {filename.vbs}

    then there you go, you just created a printer object. You can trigger this
    one via GPO

    Set WshNetwork = CreateObject("WScript.Network")

    WshNetwork.AddWindowsPrinterConnection "\\Server\Laser1"
    WshNetwork.SetDefaultPrinter "\\Server\Laser1"

    Good luck..

    Other Useful Links :-

    Expert Comment

    you could also simply use a logon script, using a .bat file command. so basically it sysvol on the server, click on the folder with your domain on it, and then click on scripts. As standard there should be a login.bat in there. If you right click on that, and then select edit, in here we can start to make commands. Make sure in AD all the users in there profile point to logon.bat file. If you dont know how to do that then ask and ill point you in the right direction. The command you want is something like this:

    net use \\server\printer name

    Make sure you set the printer up on the server before running this script. Cheers
    LVL 6

    Expert Comment

    Alternately you can use con2prt on the workstations themselves (although it's more of a pain to set up it's just easier to give specific printers by the machine if you have various rooms, etc). Con2prt is an old NT file but it still works in Windows 2003/XP

    Then create a batchfile on the machine itself that looks something like:

    @echo off
    %SystemRoot%\system32\con2prt /f
    %SystemRoot%\system32\con2prt /c \\printserver\sharename

    Remembering that the printserver can be a machine that's sharing out it's printer and obviously sharename is the name of the share for that printer. Stick this in C:\Documents and Settings\All Users\Start Menu\Programs\Startup est voila! It will run every time a user logs on connecting their printer.

    Or alternately put the batch file in the system root folder and use a log on script to run the batch file such as:

    If exist %systemroot%\BATCHFILE %systemroot%\BATCHFILE.cmd

    where BATCHFILE is the name of the batch file you've created.

    LVL 3

    Expert Comment

    if your printer supports TCP/IP, then there is no need to print via the W2k03 server. Your works stations can print directly to the printer. All is needed that the printer is configured on the work station, just like any other printer.

    The procedure is as follows:
    Go start -> settings -> printers and faxes -> Add Printer. This starts a wizard
    Click <next> and select "local printer attached to this computer"; do not select automatically detect -> <next>
    Select "Create a new port" and choose "standard TCP/IP port" -> next -> next
    You can enter the IP address of the printer and a descriptive name.

    LVL 7

    Accepted Solution

    Most of the techs above didn't fully read the request.  Here is a document I wrote some time ago that should help.

    This document describes how to create a local printer on a Windows machine without going through the Add Printer Wizard or without using other methods such as a PictureTaker package. It provides a fully- automated method for deploying printers that can be spooled directly to the printer (via TCP/IP) or via an LPR connection.

    Creating the Install Script
    The installation script is the heart of the entire process. There are two pieces to the process. The first is to setup a registry file containing the appropriately named ports, and the second is to create the appropriate RUNDLL32 command.

    Setup the Registry File
    The first step in creating the script is to setup a registry file so that the printer ports can be created if they're not already present on the system. You MUST be sure to do this. The second part of the script will NOT work if the appropriate ports are not installed! Decide on how you want to print to the printer.  You can also manually install the printer on a workstation an export this registry information.   If you're printing directly to the printer via TCP/IP, your registry file will appear in the following format:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\<hostname>]
    "SNMP Community"="public"
    "SNMP Enabled"=dword:00000001
    "SNMP Index"=dword:00000001

    Replace <hostname> with the fully-qualified domain name of the printer such as myprinter104.mydomain.local. You may also have to change the SNMP parameters depending on if the printer has SNMP support enabled. The settings provided above are the typical default settings for all HP network printers.

    If you want to print via an LPR port, your registry file will appear in the following format:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\<hostname:printer>]
    "Server Name"="<hostname>"
    "Printer Name"="<printer>"

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\<hostname:printer>\Timeouts]

    Replace <hostname> with the fully-qualified domain name of the printer server such as myprintersrv.mydomain.local and <printer> with the name of the printer spool on the server such as myprinter.

    After making changes to the registry, the Spooler service must be restarted for the new ports to be available.

    Setup the RUNDLL32 Command
    The next step is to setup the RUNDLL32 command to do the actual printer installation. The general format of the command is as follows:

    rundll32 printui.dll,PrintUIEntry /if /b "<description>" /f "%windir%\inf\ntprint.inf" /q /r "<port>" /m "<driver>" /z /u

    The <description> refers to the name of the printer that will be seen by the end-user. The <port> refers to the port you created above, for example, myprintsrv.mydomain.local:myprinter for the LPR port or myprinter.mydomain.local for the TCP/IP port. The <driver> refers to the name of the driver in the INF file that will be installed for the printer. If you do not change %windir%\inf\ntprint.inf, this is the name of a standard Windows printer driver such as HP Color Laserjet 8500 PS. You can see a full help screen for the PrintUIEntry function by typing rundll32 printui.dll,PrintUIEntry /? at a prompt. Once you've setup the command-line for each printer, it's time to put it all together into a script.

    The Installation Script
    Now that you've got all of the information you need, it's time to put it into an installation command script. The script should do the following:

    Update the registry silently to add the necessary ports.
    Stop the Spooler service.
    Start the Spooler service.
    Remove any existing printer with the same name
    Install the printer
    Below is a sample installation script for printers in MYROOM. It is in a format that can be utilized with PSEXEC, PKGADD, SMS or any other package distribution product.  It can also be distributed via login script if the end user has sufficient prvileges on the local workstation.

    REM #==========================================================================
    REM #
    REM # Filename: INSTALL.CMD
    REM # Description: Installs the printer
    REM # $Id$
    REM #
    REM #==========================================================================

    REM # Make sure the ports are created - %PROGRAM_FOLDER% is defined by
    REM # PKGADD while it is running. See the documentation for details.
    regedit /s "%PROGRAM_FOLDER%\myroom.reg"

    REM # Restart the spooler service
    net stop spooler
    net start spooler

    REM # Install all of the printers via rundll32 - This could easily be put into
    REM # a FOR loop but isn't here for readability
    REM Setting server to localhost loads the printer on the workstation executing the script.
    SET SERVER=localhost
    SET DRIVER=HP Color Laserjet 8500 PS

    REM # Remove existing printers with the same name so we don't get copy after copy
    REM # NOTE: start /wait makes us wait for rundll32 to finish before continuing
    start /wait rundll32 printui.dll,PrintUIEntry /dl /n "myroom" /q

    REM # Install the printers
    start /wait rundll32 printui.dll,PrintUIEntry /if /b "myroom" /f "%windir%\inf\ntprint.inf" /q /r "%SERVER%:myroom" /m "%DRIVER%" /z /u

    Lines in the script above may wrap for readability on the web page.

    In order to enable paper trays, duplexing options, etc. on a printer, you must first install the printer and configure it as it should be. Once you've configured the printer to your liking, issue the command: rundll32 printui.dll,PrintUIEntry /Ss /n "<printer name>" /a "<printer name>.dat" d replacing <printer name> with the actual name of the printer displayed in the Printers folder. This will save the printer data settings to a binary file so that they may be later restored. When installing the printer automatically, add the command rundll32 printui.dll,PrintUIEntry /Sr /n "<printer name>" /a "<printer name>.dat" d to the script above. That will restore the settings previously saved. It appears that these 2 steps must be done for each printer even if they are the same model.

    I hope this Helps.  Let me know if you don't understand something.  

    LVL 14

    Expert Comment

    Only for complete the firemanf29 comment there are new options  working only with w2003 and XP
    But I'm using a  batch similar to Scott solution cmd + kix + printui.dll + regedit with XP and w2000

    for reference:
    Sample scripts for retrieving information about and for configuring printer ports and printer drivers on a computer

    Printer related Scripts in Windows XP and Server 2003 (prnport.vbs prncnfg.vbs prndrv.vbs prnjobs.vbs ...)

    'Install Printer Ports on local or remote computer from MS site
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objNewPort = objWMIService.Get _

    objNewPort.Name = "IP_169.254.110.14"
    objNewPort.Protocol = 1
    objNewPort.HostAddress = ""
    objNewPort.PortNumber = "9999"
    objNewPort.SNMPEnabled = False

    LVL 1

    Expert Comment

    There has been lots of valuable input provided here. However these solutions may be confusing to implement in your situation.

    Your end result will be a scripted solution. So I ask,
         What scripting level are you comfortable with? Batch files, KIX, VB Script, etc?
    This will affect your accepted solution.

    Your end result most likely will be to add the printer information to any logon script you may be using. Are you using a Domain logon script? And if so what’s it written in (batch, kix, vb etc). If you do not use a domain logon script, you can always add the script file to the all users Startup folder.

    For some extra reading, Microsoft has a Kb article on “How to add printers with no user interaction in Windows XP” at:;en-us;314486&Product=winxp

    I can provide a custom script for you once I know more about your needs.
    LVL 7

    Expert Comment

    Here is my latest solution to this.  We use this all the time.  Addprinters.bat will ask for the workstation to add the printer to and the run addgprbilk.bat to add the printer all at once.  You need to edit all the batch files and specify the path to the batch files.  You'll also need to specify which printer you want to add.  Use these as templates.  We have one for each branch.  I've also included the batch file to delete these printers.  You'll need this if you retired a pc, decide to switch out the print server, move the pc to another branch. contains the 4 batch files to add and delete printers.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
    #Citrix #POC #XenDesktop #vCenter #VMware #ESX
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now