本帖最后由 apang 于 2014-10-10 11:00 编辑
注册表:
xp下,reg query 的 /s 和 /v 开关好像不能一起使用,改一下:- @echo off & setlocal enabledelayedexpansion
- set "v1=HKLM\SYSTEM\CurrentControlSet\Control\Network"
- set "v2=HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces"
- set "s=EnableDHCP IPAddress SubnetMask DefaultGateway"
-
- for /f "delims=" %%i in ('reg query "%v1%" /s') do (
- set "v=%%i"
- if /i "!v:~,4!" == "HKEY" (
- for %%a in ("!v!\..") do set "ID=%%~nxa"
- ) else for /f "tokens=1,2*" %%a in ("!v!") do (
- if /i "%%a" == "Name" if "%%c" == "本地连接" goto :Next
- )
- )
-
- :Next
- for /f "tokens=1,2*" %%i in ('reg query "%v2%\%ID%"^|findstr /i "%s%"')do (
- set "v=%%k" & set "%%i=!v:\0=!"
- )
-
- if /i "%EnableDHCP%" == "0x1" (
- echo,IP 地 址:%DHCPIPAddress%
- echo,子网掩码:%DHCPSubnetMask%
- echo,默认网关:%DHCPDefaultGateway%
- ) else (
- echo,IP 地 址:%IPAddress%
- echo,子网掩码:%SubnetMask%
- echo,默认网关:%DefaultGateway%
- )
- pause
复制代码
|