|
楼主 |
发表于 2017-9-2 13:32:18
|
显示全部楼层
- @echo off
- setlocal ENABLEEXTENSIONS
- wget -O temp "http://ip.chinaz.com/getip.aspx"
- cls
- for /f "tokens=2 delims='" %%i in (temp) do set result=%%i
- del temp 2>nul
- echo 外网IP是: %result%
- for /f "tokens=2* delims=]" %%i in ('wmic nicconfig where "dhcpenabled='true' and ipenabled='true'" 2^>nul get caption /value ^|find "="') do echo %%i%%j>>temp1
- for /f "tokens=2* delims=]" %%i in ('wmic nicconfig where "dhcpenabled='false' and ipenabled='true'" 2^>nul get caption /value ^|find "="') do echo %%i%%j>>temp1
- for /f "tokens=* delims= " %%a in (temp1) do echo 网卡名称:%%a|findstr /v "VMware Microsoft"&del temp1 2>nul
- for /f "tokens=2 delims==" %%i in ('wmic nicconfig where "dhcpenabled='true' and ipenabled='true'" 2^>nul get macaddress /value ^|find "="') do echo MAC地址:%%i|findstr /v "00:0C:29 00:50:56 02:00:4C"
- for /f "tokens=2 delims==" %%i in ('wmic nicconfig where "dhcpenabled='false' and ipenabled='true'" 2^>nul get macaddress /value ^|find "="') do echo MAC地址:%%i|findstr /v "00:0C:29 00:50:56 02:00:4C"
- set "i=0.0.0.0" & set "j="
- for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
- if not defined j for %%b in (%%a) do set "i=%%b" & set "j=1")
- echo IP地址:%i%
- for /f tokens^=2^,4delims^=^" %%i in ('wmic nicconfig where "dhcpenabled='true' and ipenabled='true'" 2^>nul get IPSubnet /value ^|find "="') do echo 子网掩码:%%i %%j
- for /f tokens^=2^,4delims^=^" %%i in ('wmic nicconfig where "dhcpenabled='false' and ipenabled='true'" 2^>nul get IPSubnet /value ^|find "="') do echo 子网掩码:%%i %%j
- for /f "tokens=3" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
- if not defined k for %%b in (%%a) do set "g=%%b" & set "k=1")
- echo 默认网关:%g%
- for /f tokens^=2^,4delims^=^" %%i in ('wmic nicconfig where "dhcpenabled='true' and ipenabled='true'" 2^>nul get DNSServerSearchOrder /value ^|find "="') do echo 首选DNS:%%i&echo 备用DNS:%%j
- for /f tokens^=2^,4delims^=^" %%i in ('wmic nicconfig where "dhcpenabled='false' and ipenabled='true'" 2^>nul get DNSServerSearchOrder /value ^|find "="') do echo 首选DNS:%%i&echo 备用DNS:%%j
- echo 下面是出网路由路径显示
- echo 稍微有点慢,请等待
- for /F "skip=3 delims=" %%i in ('tracert -d 114.114.114.114') do echo %%i
- pause >nul
复制代码
最终定稿
获取有效网络数据.rar
(385.24 KB, 下载次数: 61)
|
|