Driss Posted April 6, 2004 Posted April 6, 2004 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
Driss Posted April 6, 2004 Author Posted April 6, 2004 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
Driss Posted April 6, 2004 Author Posted April 6, 2004 Tomorrow I will post reg entries of 2 or 3 win 98 machines with different printers so you can see how they differ. Thanks again Driss
ZenKensei Posted April 7, 2004 Posted April 7, 2004 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
Driss Posted April 7, 2004 Author Posted April 7, 2004 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
Driss Posted April 7, 2004 Author Posted April 7, 2004 Thanks Larry, I knew it will come down to export replace and import. I will give it a try Thanks agin Driss
Driss Posted April 9, 2004 Author Posted April 9, 2004 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
Dan Posted April 9, 2004 Posted April 9, 2004 This will read your regfile, replace the string and write a new file. 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)
Driss Posted April 9, 2004 Author Posted April 9, 2004 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
Dan Posted April 9, 2004 Posted April 9, 2004 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.
Driss Posted April 9, 2004 Author Posted April 9, 2004 Yes it was the space, it worked perfectly Thanks a lot Dan Cheers
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now