I'm writing a simple script to retreive my localhost address given as IP.
To get my IPv4 address (Win7) I've written simple FOR loop, but as a result i get the IP from last loop instead of first one.
Here is the batch code:
cls
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do (
set ip=%%b
)
set ip=%ip:~1%
echo %ip%
this returns:
(set ip= 192.168.1.101 )
(set ip= 192.168.88.1 )
(set ip= 192.168.137.1 )
set ip=192.168.137.1
echo 192.168.137.1
192.168.137.1
What i need is the result of first loop:
192.168.1.101
Also code with @aschipfl
:SKIP
solutionAnd what about this code without any loop ?