Script to find replace Ip's on local printer ports?

Hello,
We are switching over our internal ip range, does anyone know of a script or what's needed to make a script to change the ip address on Local Tcpip printer ports?  I'm looking to add it to a login script so I don't have to run around to every desktop, login as each user that uses it and change their printer ports. (Mostly 2000 pro some xp).

For example if I could just list every ip address of the current network printers and do an if exists.....replace..... kind of deal.  This would be a HUGE help :).  Thanks.
devinp619Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GnartCommented:
I don't know of any script, but you can:

a) look up which users are authorized for the specific IP address of the printer using your AD.
b) export the registry entry for the each specific IP from your own machine.
c) have it (through group policy, login script, etc...) when the user logon run the .reg file to replace the existing entry in the registry.

d) if you have remote management you can also do the more specific ones using remote management.

Registry search for the IP to locate the key and export or look
\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports

hope that help.....  may be someone has a script or program to read the IP address in the key and do a compare before importing the .reg file.

cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chicagoanCommented:
you can set up the new printers on one machine, export the registry entries and import them in the login script
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\(port name)

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

or rundll
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q189/1/05.ASP&NoWebContent=1

(better examples here: http://www.robvanderwoude.com/index.html )
0
GnartCommented:
chicagoan,

Why not just put in "regedit xxx.reg" in the script via policy as I suggested?

cheers
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

chicagoanCommented:
why not indeed!
I fully support that avenue!
there are others, depending on the administrator's familiarity and comfort level
0
devinp619Author Commented:
Thank you guys for the comments, I'll play around with them a little and close out soon, Thank you very much.
0
KheldarozCommented:
Try this, there's also a csv file with the following data

Stores HP6P              172.16.1.55
Path Micro Laser         172.16.1.57
GONH_HP2200         172.16.1.58
CRMH_HP4600          172.16.1.59



'Printer Update
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Printers = WshNetwork.EnumPrinterConnections

For i = 0 to Printers.Count - 1 step 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("y:\printerip.csv", 1)
      Do Until objTextFile.AtEndOfStream
          strNextLine = objTextFile.Readline
          arrServiceList = Split(strNextLine , ",")
            ip = arrServiceList(1)
            newip = arrServiceList(0)
              if Printers.Item(i) = "IP_" & ip then
                 print1 = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\" & printers.item(i+1) & "\"
                 print2 = print1 & "DsSpooler\"
                        print3 = "HKLM\system\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\"
                 print4 = print3 & Printers.Item(i) & "\"
                 print5 = "HKLM\system\CurrentControlSet\Control\Print\Printers\" & printers.item(i+1) & "\"
                 print6 = print5 & "DsSpooler\"
                 WScript.Echo "Printer " &Printers.Item(i+1) &" has been updated"
                 WSHShell.RegWrite print1 & "Port", "IP_" & newip
                 WSHShell.RegWrite print2 & "PortName", "IP_" & newip
                 WSHShell.RegWrite print4 & "IPaddress", newip
                 WSHShell.RegWrite print5 & "Port", "IP_" & newip
                 WSHShell.RegWrite print6 & "PortName", "IP_" & newip
              end if
      Loop
next
WScript.Echo "Printers have been updated"
0
KheldarozCommented:
change from IP to Host name printing

'Printer Update
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Printers = WshNetwork.EnumPrinterConnections

For i = 0 to Printers.Count - 1 step 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("y:\printerip.csv", 1)
      Do Until objTextFile.AtEndOfStream
          strNextLine = objTextFile.Readline
          arrServiceList = Split(strNextLine , ",")
'          Wscript.Echo "Printer name: " & arrServiceList(0) &" IP: " & arrServiceList(1)
            ip = arrServiceList(1)
            newip = arrServiceList(0)
              if Printers.Item(i) = "IP_" & ip then
                 print3 = "HKLM\system\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\"
                 print4 = print3 & Printers.Item(i) & "\"
                 WSHShell.RegWrite print4 & "HostName", newip
                 WSHShell.RegWrite print4 & "IPAddress", ""
                 WScript.Echo "Printer " &Printers.Item(i+1) &" has been updated"
              end if
      Loop
next
WScript.Echo "Printers have been updated"
'end Printer update
0
amcolitCommented:
So how did this work? What information was stored in the CSV file?
0
amcolitCommented:

I created a csv file containing  old , new IP address of the printers I want to chang. Im getting an the error however:  (wondering if I need more in the csv file).
 
Windows script error
 
Line: 22
Char : 18
Error: Object required:wshshell
Code:800a01a8
Souce: Microsoft VBscript Runtime error
 
 
 
'Printer Update
 
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Printers = WshNetwork.EnumPrinterConnections
 
For i = 0 to Printers.Count - 1 step 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\temp\test.txt", 1)
      Do Until objTextFile.AtEndOfStream
          strNextLine = objTextFile.Readline
          arrServiceList = Split(strNextLine , ",")
            ip = arrServiceList(1)
            newip = arrServiceList(0)
              if Printers.Item(i) = "IP_" & ip then
                 print1 = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\" & printers.item(i+1) & "\"
                 print2 = print1 & "DsSpooler\"
                        print3 = "HKLM\system\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\"
                 print4 = print3 & Printers.Item(i) & "\"
                 print5 = "HKLM\system\CurrentControlSet\Control\Print\Printers\" & printers.item(i+1) & "\"
                 print6 = print5 & "DsSpooler\"
                 WScript.Echo "Printer " &Printers.Item(i+1) &" has been updated"
                 WSHShell.RegWrite print1 & "Port", "IP_" & newip
                 WSHShell.RegWrite print2 & "PortName", "IP_" & newip
                 WSHShell.RegWrite print4 & "IPaddress", newip
                 WSHShell.RegWrite print5 & "Port", "IP_" & newip
                 WSHShell.RegWrite print6 & "PortName", "IP_" & newip
              end if
      Loop
next
WScript.Echo "Printers have been updated"
 


0
KheldarozCommented:
if i remember the CSV file only had 2 fields "name","ipadress"
0
amcolitCommented:
I'm getting some scripting errors, were any further modifcations made to the script?
 
0
KheldarozCommented:
it was four years ago but i don't believe so
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking

From novice to tech pro — start learning today.