Last number in IP Address

Joined
May 24, 2013
Messages
1
Reaction score
0
I'm after a DOS BAT file which wills store into varables the last numbers of a PC's IP Address. EG I want to store in varables 10 from 192.168.103.10.

I have...
for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set tempip=%%a)
set tempip=%tempip: =%
echo %tempip%
pause

Just can find out how to store that last part of the IP Address (ie 10).
 
Hi Jason, welcome to the forums!

I'm really rusty with BAT programming, but this may work?

for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set tempip=%%a)
set tempip=%tempip: =%
for /f "delims=. tokens=4" %%g in ("%tempip%") do echo %%g
pause
 
Back
Top