Hi,
We have about 100 windows 98 boxes, each box has a different printers Installed with a TCP/IP local port and comunicate straight to the printer through its static IP. We want to change the IP addresses of these printers and run script on win98 to search the registry for the old IPs and replace them with the new ones. Can search and replace registry values be done with Autoit? if so can any one please shad some light.
Thank you
Drisco
Page 1 of 1
Change Printer Ip Search registry and replace
#2
Posted 06 April 2004 - 05:46 PM
Hi Larry,
See the thing is each win98 machine has 2 or up to 4 different printers installed all through a TCP/IP local port, and I don't know which printers are Installed where. I just have the IP addresses of the 20 or so printers, so I was thinking may be there could be something like
If registry Exist, 68.76.x.x then replace with 172.16.x.x
I hope I clearified it better
Thank you
See the thing is each win98 machine has 2 or up to 4 different printers installed all through a TCP/IP local port, and I don't know which printers are Installed where. I just have the IP addresses of the 20 or so printers, so I was thinking may be there could be something like
If registry Exist, 68.76.x.x then replace with 172.16.x.x
I hope I clearified it better
Thank you
#4
Posted 07 April 2004 - 02:26 AM
You may be planning to do this already, but if not consider this. Use a program (Regsnap or something similar) that can compare registry changes, take a snapshot of the registry as it currently is. Then, change the IP address of one of the printers to the corresponding 'new' IP on that machine and take another snapshot afterwards and compare the changes in the registry. Assuming that the printer models do not change, the drivers should not change and it should be relatively easy to see what keys are effected that relate to the IP Address.
Z/K
Z/K
#5
Posted 07 April 2004 - 07:19 PM
Thanks ZenKensei for the tip
I can change the IP manualy from the registry, and all works fine, but I need to do this from the logon script, the registry keys differ on all machines, I also don't know what printers are Installed where, I just want to be able to search for ip under print hive and simply replace it with the corresponding new IP, I have the ip addresses of all printers, we will be replacing the printers IP addresses as an example
172.16.1.40 to 10.10.10.40
172.16.1.43 to 10.10.10.41
172.16.1.45 to 10.10.10.70
172.16.1.20 to 10.10.10.99
So the machines old ip will need to be replaced as well. bellow is a reg key from one machine
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Monitors\HP JetDirect Port\Ports\NPI8C3491]
"NetworkProtocol"=dword:00000002
"PortNumber"=dword:00000000
"HPNetworkPrinterID"="TCPIP,172.16.1.42,0"
"HWAddress"=hex:00,01,e6,8c,34,91
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Monitors\HP JetDirect Port\Ports\NPI4FD688]
"NetworkProtocol"=dword:00000002
"PortNumber"=dword:00000000
"HPNetworkPrinterID"="TCPIP,172.16.1.44,0"
"HWAddress"=hex:00,01,e6,4f,d6,88
if this cannot be done using Autoit what would be the best approch.
Thank you all
Driss
I can change the IP manualy from the registry, and all works fine, but I need to do this from the logon script, the registry keys differ on all machines, I also don't know what printers are Installed where, I just want to be able to search for ip under print hive and simply replace it with the corresponding new IP, I have the ip addresses of all printers, we will be replacing the printers IP addresses as an example
172.16.1.40 to 10.10.10.40
172.16.1.43 to 10.10.10.41
172.16.1.45 to 10.10.10.70
172.16.1.20 to 10.10.10.99
So the machines old ip will need to be replaced as well. bellow is a reg key from one machine
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Monitors\HP JetDirect Port\Ports\NPI8C3491]
"NetworkProtocol"=dword:00000002
"PortNumber"=dword:00000000
"HPNetworkPrinterID"="TCPIP,172.16.1.42,0"
"HWAddress"=hex:00,01,e6,8c,34,91
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Monitors\HP JetDirect Port\Ports\NPI4FD688]
"NetworkProtocol"=dword:00000002
"PortNumber"=dword:00000000
"HPNetworkPrinterID"="TCPIP,172.16.1.44,0"
"HWAddress"=hex:00,01,e6,4f,d6,88
if this cannot be done using Autoit what would be the best approch.
Thank you all
Driss
#7
Posted 09 April 2004 - 04:51 AM
More help needed,
Ok. I exported the registry ports key, but was unsuccessful getting String Replace to work for me. I have searched the help file, this forum, and the Internet before posting here and was not successful replacing a single word in the .reg file :(
Example:
I am trying to search for 172.16.1.24 only if found then replace it with 10.10.10.27
I also need NOT to change the key "IP_172.16.1.24" because it is a key and it will write a whole new key under ports and not replace it after I import it.
From c:\printerreg.reg
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_172.16.1.24]
"Protocol"=dword:00000001
"Version"=dword:00000001
"HostName"=""
"IPAddress"= "172.16.1.24"
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"="public"
"SNMP Enabled"=dword:00000001
"SNMP Index"=dword:00000001
I have a long autoit ver 2 script that does a lots of basic functions and they all work perfectly, So any help that I can add to it since it's not ver 3 would be appreciated, but at this point I can use any help I can get.
Thanks
Ok. I exported the registry ports key, but was unsuccessful getting String Replace to work for me. I have searched the help file, this forum, and the Internet before posting here and was not successful replacing a single word in the .reg file :(
Example:
I am trying to search for 172.16.1.24 only if found then replace it with 10.10.10.27
I also need NOT to change the key "IP_172.16.1.24" because it is a key and it will write a whole new key under ports and not replace it after I import it.
From c:\printerreg.reg
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_172.16.1.24]
"Protocol"=dword:00000001
"Version"=dword:00000001
"HostName"=""
"IPAddress"= "172.16.1.24"
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"="public"
"SNMP Enabled"=dword:00000001
"SNMP Index"=dword:00000001
I have a long autoit ver 2 script that does a lots of basic functions and they all work perfectly, So any help that I can add to it since it's not ver 3 would be appreciated, but at this point I can use any help I can get.
Thanks
#8
Posted 09 April 2004 - 06:13 AM
This will read your regfile, replace the string and write a new file.
[ code='text' ] ( Popup )
Dim $INFILEHANDLE, $OUTFILEHANDLE Dim $DATA, $INFILE, $OUTFILE $INFILE = ".\print.reg" $OUTFILE = ".\newprint.reg" $INFILEHANDLE = FileOpen($INFILE, 0) $DATA = FileRead($INFILEHANDLE,FileGetSize($INFILE)) $DATA = StringReplace($DATA, '"IPAddress"= "172.16.1.24"', '"IPAddress"= "10.10.10.27"') $OUTFILEHANDLE = FileOpen($OUTFILE,2) FileWrite($OUTFILEHANDLE, $DATA) FileClose($INFILE) FileClose($OUTFILEHANDLE)
#9
Posted 09 April 2004 - 07:50 AM
Hi again,
When I export the key using regedit /e the file is exported in a unicode and the new file is created, but it's empty.
When I export the file using regedit /a the file is exported as an ANSI, the new file is created with same content, but nothing is replaced. Am I doing something wrong?
Thanks
When I export the key using regedit /e the file is exported in a unicode and the new file is created, but it's empty.
When I export the file using regedit /a the file is exported as an ANSI, the new file is created with same content, but nothing is replaced. Am I doing something wrong?
Thanks
#10
Posted 09 April 2004 - 08:02 AM
your .reg file had a space after the = which are not normally present in an export file. "IPAddress"= "172.16.1.24"
You may just need to remove the space from this line to make it work.
I exported using regedit /e /a print.reg "hkey......" and it worked. I'm using windows xp pro, that may have something to do with it.
You may just need to remove the space from this line to make it work.
I exported using regedit /e /a print.reg "hkey......" and it worked. I'm using windows xp pro, that may have something to do with it.
Page 1 of 1

Sign In
Register
Help
MultiQuote