• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2272
  • Last Modified:

Howto change/reassign printer IP ports to new printer IP ports with scripting

Please help!

The company do have more than 200 PC logged into a NT40 Domain.
We are going to upgrade to Windows 2003 Server with AD.

Before this our IP addresses also have to be changed. We have public IP addresses, which we
must change to privat IP adresses for the whole system. This task must be done first.

This gives us a problem, as all printers are connected directly to the printers with different
IP port assignments on the client machines (all XP Prof). We want to continue with this solution.

We use:  HP Standard TCP/IP Port,   Lexmark Network Port,   OKI LPR Port, Crown Port+   and   Standard TCP/IP Port.

We tried exporting the printer specific registry keys like
HKEY_LOCAL_MACHINE\SOFTWARE\Hewlett-Packard - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print -
HKEY_LOCAL_MACHINE\SOFTWARE\Minolta-QMS\Crown Print Monitor+ - HKEY_LOCAL_MACHINE\SOFTWARE\Okidata\OKI LPR Utility -
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\print - etc

In a test system we were able to make search and replace on the IP adresses in the exported REG files.
Ufortunately there are some binary data in the reg files containing the IP adresses of the printer ports which we could not replace with the new IP adresses.

Is there an easier solution for our project to change IP printer port assignments on client machines.

Sincirely, Birger

0
birgeradslhomedk
Asked:
birgeradslhomedk
1 Solution
 
zeppelinx12Commented:
Set Static addresses for the printers. Then set the addresses on the clients globally.
0
 
NYtechGuyCommented:

Birger-

I realize you mentioned that you would like to "continue to use this solution" - but this may be an ideal time to setup a print server in your organization to optimize your printing environment.  

Once you have a server(s) setup with all of your printers, you can share them out to clients - and then map them to the clients in a login script.  In that same login script you can delete old printers, add new ones, etc.

This allows for centralized control in a network - which would not be a bad thing with 200+ PCs in your organization.  

Please let me know your thoughts.

/Justin  
0
 
birgeradslhomedkAuthor Commented:
You are right about this.

But our network struckture has to be optimized so that communication
between client and printer is as close as possible to each other.  This
is because of bottlenecks in the bandwidth and some VPN tunnels.
Client/server application, terminal services and other programs must have full bandwidth.  

Upgrading the network is a project for the next year.

Thanks for the response.
Birger
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
birgeradslhomedkAuthor Commented:
NYtechGuy
Next year we also will have a new Printer Output system.
For now we have to use the solution I mentioned

zeppelinx12
About "Set Static addresses for the printers".
They have IP adresses given by Reserverved DHCP IP adresses. No problem here.

About "Then set the addresses on the clients globally"
I am not sure what you mean with this globally.

What I need is an automatically change/reassignment of the client Printer IP ports.

Birger
0
 
NYtechGuyCommented:

Understood - makes sense.

If in fact you can do this by registry, how will you implement this?  Manually or via script, etc?

/justin
0
 
NYtechGuyCommented:


Hopefully these links can assist you-


PRNPORT.VBS - Printer Port Control
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/prnport.mspx?mfr=true 

Command Line Printer Control - Windows 2000 & XP
http://www.robvanderwoude.com/index.html

0
 
birgeradslhomedkAuthor Commented:
NYtechGuy

Implementing is no problem. We have succeded with that.
Batch file in login script. Using reg command.

What we have tried is
Exporting relevant registry keys with reg command to REG files on a centralised location for each client.
In the REG files we have replaced the old IP references and replace with new IP adresses

The shift to new IP adresses will be done over a weekend:

On the 1st logon the clients will have a special script where
Old registry keys wil be deleted and the edited REG files will be imported

All this works fine in the test system.

The problem in this this method is that the REG files have binary stored information
about the printer IP ports. The good side is that we can handle different
Network Printer Ports from several printer deliverer.
 
On way is to make a machine with the new adresses, and the exporting them. The new binary values from the REG file
can then be added to the modified REG files by search and replace utility

What I hoped for is a smart script in a loggon script, that just finds printerports and the reassigns them automatically with new IP's,
which of couse must be putted into the script.

Sincirely Birger


0
 
birgeradslhomedkAuthor Commented:
NYtechGuy

I have seen those links and are aware of them.

I have just not found a way to change a port value with a script. It is possible to
add and delete. But I want to change the ports.

Also they are only for Standard IP/TCP ports.

Birger
0
 
NYtechGuyCommented:

I realize that changing would be optimal, but is it possible to delete and then to readd?

0
 
birgeradslhomedkAuthor Commented:
Yes

From the exported the reg files we created temporary REG files where we
added the minus sign before the HKLM and rerun it tvice in the logon script. The information of the
ports are remove this way. This must be done to get rid of the old port assigment.
Afterwards we added the modified Reg files.

I think we have to do search and replace of the binary values in the exported REG files.

I did it for two printers and they worked fine in the test enviroment.

It would have been easier with a script designed only for reassigning IP ports for
already existing printers on the client machine.

Birger
0
 
DCreatureCommented:
"But our network struckture has to be optimized so that communication
between client and printer"

QoS.
0
 
canaliCommented:

Try this script, and tell me if I understood your needs

Gas
' --------------- prnIPchange.vbs ---------------
'Change all ip occurrences in printer tcp  
' Gas ver 0.01
'---------------------------------------------------
sub FindPRNandChangeIP (ip,newip)
     strComputer = "."
     Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colPorts =  objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort")
   
    For Each objPort in colPorts
         if  objPort.HostAddress = OldIp       then
               cngPRNport objPort.Name, NewIp
         end if            
    Next
end sub

sub cngPRNport (Name,newip)
  strComputer = "."
  Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  Set objNewPort = objWMIService.Get _
      ("Win32_TCPIPPrinterPort").SpawnInstance_
  objNewPort.Name = Name
  objNewPort.HostAddress = newip
  objNewPort.Put_
end sub
sub listPRNport
  strComputer = "."
  Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  Set colPorts =  objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort")
   For Each objPort in colPorts
    Wscript.Echo "Description: " & objPort.Description
    Wscript.Echo "Host Address: " & objPort.HostAddress
    Wscript.Echo "Name: " & objPort.Name
    Wscript.Echo "Port Number: " & objPort.PortNumber
    Wscript.Echo "Protocol: " & objPort.Protocol
    Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity
    Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex
    Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled
  Next
end sub
Dim oArgs,Counter
Set oArgs = WScript.Arguments
Counter = oArgs.Count
If (Counter <> 2) Then
   WScript.echo "Wrong parameters"
   WScript.echo "---------list printer ports-------------------"
   listPRNport
   WScript.echo "-------------------------------------------"
   WScript.echo "Wrong parameters"
   WScript.echo "Usage:  cscript prnIPchange.vbs OldIp NewIp"
   WScript.Quit 1
end if
OldIp=oArgs.item(0)
NewIp=oArgs.item(1)
FindPRNandChangeIP OldIp, NewIp

set oArgs=Nothing
0
 
birgeradslhomedkAuthor Commented:
Thank you forthe script

Indeed it changes the value for the printer ports "Standard TCP/IP Port".
But it seems that the keyname still is the old one.

Also it can not change the other types of IP port assignments.

I think I will use my way. It has only to be done once.

Thank you all for help


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now