回复 7# 小智BAT
这个仅显示 没测试多网卡 设置的话 WMIC应该也可以哦- @echo off&setlocal enabledelayedexpansion
- set "str=DefaultIPGateway^,IPAddress^,DNSServerSearchOrder^,IPSubnet^,DHCPEnabled"
- for /f "skip=1tokens=1*" %%i in ('wmic Nic where "Manufacturer<>'Microsoft' and NetConnectionStatus='2'" get Index^,NetConnectionID^') do (
- for /f %%j in ("%%j") do (
- echo 当前连接:%%j
- for /f "tokens=1,2 delims={}," %%a in ('wmic Nicconfig where "Index='%%i'" get %str% /value') do (
- for /f %%c in ("%%a%%~b") do set %%c
- )
- if /i "!DHCPEnabled!" == "TRUE" (
- echo 当前获取IP模式:自动
- ) else echo 当前获取IP模式:手动
- echo 默认网关: !DefaultIPGateway!
- echo ip地址: !IPAddress!
- echo 主DNS: !DNSServerSearchOrder!
- echo 子网掩码: !IPSubnet!
- )
- )
- pause
复制代码 当然也可以获取 SettingID 后再在注册表里直接获取或修改 |