- @echo off & setlocal enabledelayedexpansion
- echo =-----------------------------------------=
- echo = 本BAT只列出一个有线和一个无线的IP信息 =
- echo = 读取信息请耐心等待 =
- echo =-----------------------------------------=
- echo.
- for /f "tokens=1 delims=[]" %%i in ('%SystemRoot%\system32\nbtstat -S^|find /n "以太网:"') do (
- nbtstat -S | more +%%i >$
- set /p Str=<$
- del $
- for /f "tokens=2 delims=[]" %%i in ('echo "!Str!"') do set LIP=%%i
- )
- for /f "tokens=1 delims=[]" %%i in ('%SystemRoot%\system32\nbtstat -S^|find /n "WLAN:"') do (
- nbtstat -S | more +%%i >$
- set /p Str=<$
- del $
- for /f "tokens=2 delims=[]" %%i in ('echo "!Str!"') do set WIP=%%i
- )
- for /f "tokens=16" %%i in ('ipconfig /all ^| find /i "IPv4 地址"') do set ip=%%i ?
-
- echo =================================================== >%tmp%\ip-mac.txt
- echo 当前时间:%DATE% >>%tmp%\ip-mac.txt
- echo =================================================== >>%tmp%\ip-mac.txt
- echo 本机用户名为:%COMPUTERNAME% >>%tmp%\ip-mac.txt
- echo 本机有线IP为:%LIP% >>%tmp%\ip-mac.txt
- echo 本机无线IP为:%WIP% >>%tmp%\ip-mac.txt
- ::echo 本机首选IP为:%ip% >>%tmp%\ip-mac.txt
- echo 本机物理地址: >>%tmp%\ip-mac.txt
- echo ===================================================
- for /f "tokens=1,3 delims=," %%i in ('getmac /v /nh /fo:csv ^| findstr
- "..-..-..-..-..-.."') do (
- echo %%i %%j >>%tmp%\ip-mac.txt
- )
- echo =================================================== >>%tmp%\ip-mac.txt
- ipconfig | findstr /i "以太网 无线 IPv4">>%tmp%\ip-mac.txt
- Start %tmp%\ip-mac.txt
复制代码 这个只能获取到当前的实体网卡ip,不能获取到外置网卡的ip,求教! |