- @echo off
- Setlocal enabledelayedexpansion
- cls
- Echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- Echo.
- 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 "tokens=1* delims=:" %%j in ("%%j") do (
- Set $%%i=%%j
-
- Echo %%j -
- for /f "tokens=1-3delims={}," %%a in ('wmic nicconfig where "index='%%i'" get %str% /value') do (
- for /f %%c in (%%c) do IF /i "%%a" == "dnsserversearchorder=" Set "dns2=%%c"
- for /f %%c in ("%%a%%~b") do Set "%%c"
- )
- set %%j="%%j:~0,4%"
- IF /i "!dhcpenabled!" == "true" ( Echo. 网卡名称:%%j获取方式:自动获取) else ( Echo. 网卡名称:%%j获取方式:指定地址 )
- )
- )
- Echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- pause
复制代码 每次获取本地连接都有个TAB符号,想做个备份读取%%j本地连接做个备份 被这个TAB符号难倒了 求你看~ |