@echo off
setlocal

:: 使用 ipconfig 查找 IPv4 位址，並使用 findstr 過濾
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /i "IPv4" ^| findstr /v "Disconn" ^| findstr /v "Media" ') do (
    set "IPV4_ADDRESS=%%a"
    goto :copy
)
goto :eof

:copy
:: 清理並複製到剪貼簿
set "IPV4_ADDRESS=%IPV4_ADDRESS: =%"
echo|set /p=%IPV4_ADDRESS%|clip

echo.
echo IPv4 位址已複製到剪貼簿: %IPV4_ADDRESS%
echo.
pause