0

enter image description here 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?

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
brad
  • 870
  • 2
  • 13
  • 38
  • Look there, this may help: http://stackoverflow.com/questions/16815879/store-ip-address-in-variable-windows-version-independent – tereru Dec 22 '13 at 10:48

3 Answers3

1
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('ipconfig ^| find /i "IPv4 Address"') do (set VarIP=!%%a%!)
Echo Your PPP IP : %VarIP%
SachaDee
  • 9,245
  • 3
  • 23
  • 33
1
@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
foxidrive
  • 40,353
  • 10
  • 53
  • 68
0

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%
Sunny
  • 7,812
  • 10
  • 34
  • 48