I need the ppp IP address stored into a variable.
The only way I have found is 'ipconfig > text.txt' into a tmp file and then script a search for the ppp interface. This is very dirty.
Is there an better alternative in windows?
I need the ppp IP address stored into a variable.
The only way I have found is 'ipconfig > text.txt' into a tmp file and then script a search for the ppp interface. This is very dirty.
Is there an better alternative in windows?
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('ipconfig ^| find /i "IPv4 Address"') do (set VarIP=!%%a%!)
Echo Your PPP IP : %VarIP%
@echo off
for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get IPAddress /value | find "I" "') do echo IPv4 %%~a IPV6 %%~b
pause
You can also extract using ping:
@echo off
FOR /F "tokens=2,3" %%A IN ('ping %computername% -n 1 -4') DO IF "from"== "%%A" set "IP=%%~B"
echo %IP:~0,-1%