Cannot really visit that api.ipify.org
website, but I guess this task is essentially visit a URL that response json, and get a field out of it. Here is an example using curl
and common string-splitting-and-matching techniques in batch script. You might need to adjust the tokens
to match the sequence of response. I tested with one of my local REST service and it's fine.
@echo off
FOR /F "tokens=2 delims=:{}" %%A IN ('curl -s "https://api.ipify.org?format=json" ^| findstr "ip"') DO SET IP=%%A
SET IP=%IP:"=%
echo %IP%
pause
That being said, this is pure pain, and the method is certainly not robust. Is calling powershell from batch an option? like the accepted answer in this question.