x
ChatBox

Please log in with password to access chatbox.
visitor stats
Index | Back | Reply | New Topic

IP Change Automation

IP under Windows 7 RC
2009-06-29 23:53
hellowienIf someone installs 7 RC there will be some problems with scripts that compare IPs, as ipconfig under Windows 7 gives much more information and differs between IPv4 and IPv6 as both are supported. Besides all adapters in the system get listed, so the find ''IP-Ad" command won't work any longer. You will have to search for "IPv4" and it can be, that you get more than one result for the active adapters in your system. Moreover "tokens=13,*" doesn't deliver your IP anymore and has to be changed to "tokens=12,*" In most cases the actual IP will be given out with the first adapter in the system, so you have to check the IP out of the first line, ... with previous scripts you get the IP from the last adapter listed with ipconfig. There is the problem! A quick check can be done with following snippet from Command Prompt:

for /f "tokens=12,*" %i in ('ipconfig^|find "IPv4"') do @set IP=%j
echo %IP%

Check the output and compare it against e.g. http://www.whatismyip.com/ - in most cases there is a difference. If not, you are happy and only need to change the tokens. I did a small workaround if you get an output of more than 1 IPv4 and yours is the first one listed with ipconfig, ... maybe someone will find a smarter solution and could post it here, as it is only a matter of time, that Windows 7 will be sold and used ...

ipconfig|find "IPv4" >%temp%/allips.txt
for /F "delims=" %%i in (%temp%/allips.txt) do if not defined line set "line=%%i"
echo %line%>allips.txt
for /f "tokens=13*" %%i in ('type%temp%/ allips.txt') do set IP=%%i

What is this all for? The first line writes all found IPv4's in a file, second line separetes the first line from the file and third writes it back so we stay with only one IP-line, fourth one separetes the IP (strange, --> tokens=13 in this case!). Get another two lines (echo %IP% / pause) to see the output. I am shure you are able to integrate the additional lines into your batch if you use the method of IP-comparement.
2009-06-30 09:56
KRA92i'm using scripts and Windows 7 and my little script doesn't looks dificult XD

just changing IP, making Visits again new IP and finish :)