Windows shell scripting - function
On this page you can find some functions (special blocks of code) for Windows shell scripting. Feel free to include those functions into your scripts.
get_ip_addresses
This functions output all IPv4 addresses assigned to your system.
OS language: Independent (poorly tested)
OS version: Windows 2000 and higher
@echo off & setlocal ENABLEDELAYEDEXPANSION
set semaphore=0
for /f "tokens=2 delims=:" %%a in ('ipconfig') do (
echo %%a | findstr /R [0-9]*\.[0-9]*\.[0-9]*\.[0-9]* > NUL
if not "!errorlevel!"=="1" (
set /a semaphore=!semaphore!+1
if "!semaphore!"=="1" set ipaddr=%%a
if "!semaphore!"=="2" (
set semaphore=0
set ipaddr=!ipaddr:~1!
echo !ipaddr!
)
) else (
set semaphore=0
)
)

