Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Add Standard TCP/IP Printer

Posted on 2006-05-05
8
Medium Priority
?
4,219 Views
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.
0
Comment
Question by:willtomaz808
8 Comments
 
LVL 7

Expert Comment

by:sunilcomputer
ID: 16613054
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 :-

http://technet2.microsoft.com/WindowsServer/en/Library/ab8d75f8-9b35-4e3e-a344-90d7799927231033.mspx

http://www.mcse.ms/archive47-2004-11-1253982.html
0
 

Expert Comment

by:dcleaver
ID: 16613151
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
0
 
LVL 6

Expert Comment

by:ian_chard
ID: 16613828
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

http://support.microsoft.com/?kbid=181663

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.

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:hfern
ID: 16614378
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.




0
 
LVL 7

Accepted Solution

by:
firemanf29 earned 1000 total points
ID: 16615118
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:

REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\<hostname>]
"Protocol"=dword:00000001
"Version"=dword:00000001
"HostName"="<hostname>"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:0000238c
"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:

REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\<hostname:printer>]
"Server Name"="<hostname>"
"Printer Name"="<printer>"
"OldSunCompatibility"=dword:00000000
"HpUxCompatibility"=dword:00000000
"EnableBannerPage"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\<hostname:printer>\Timeouts]
"CommandTimeout"=dword:00000078
"DataTimeout"=dword:0000012c

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.

NOTE:
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.

@ECHO OFF
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

NOTE:
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.  

Scott
0
 
LVL 14

Expert Comment

by:canali
ID: 16618581
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
http://www.microsoft.com/technet/scriptcenter/scripts/printing/ports/default.mspx

Printer related Scripts in Windows XP and Server 2003 (prnport.vbs prncnfg.vbs prndrv.vbs prnjobs.vbs ...)
http://members.shaw.ca/bsanders/Printer%20Scripts.htm

'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 _
    ("Win32_TCPIPPrinterPort").SpawnInstance_

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

0
 
LVL 1

Expert Comment

by:JexPam
ID: 16632662
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:
http://support.microsoft.com/default.aspx?scid=kb;en-us;314486&Product=winxp

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

Expert Comment

by:firemanf29
ID: 22318296
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.  Share.zip contains the 4 batch files to add and delete printers.  
Share.zip
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

578 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