用POWERSHELL 簡單一點
$result=netsh interface ipv4 show address name="網卡名稱"|Find "IP Address"
$res2=$result.TrimStart("IP Address:")
$res2.split('.')[2]
echo off
setlocal enabledelayedexpansion
for /f "usebackq tokens=*" %%a in (ipconfig ^| findstr /i "ipv4"
) do (
for /f delims^=^:^ tokens^=2 %%b in ('echo %%a') do (
for /f "tokens=1-4 delims=." %%c in ("%%b") do (
set _o1=%%c
set _o2=%%d
set _o3=%%e
set _o4=%%f
echo !_o3!
)
)
)