本帖最后由 pcl_test 于 2015-11-29 22:35 编辑
- @echo off&color 0e
- ::正在连接中的IP地址查询
- for /f "delims=" %%i in ('getmac /v /nh /fo:csv') do (
- if /i not "%%~i"=="%%~nxi" (
- for /f "tokens=1,2,3,* delims=," %%j in ("%%i") do (
- if not defined #_network_name set "#_network_name=%%~j"
- if not defined #_network_adapter set "#_network_adapter=%%~k"
- if not defined #_network_mac set "#_network_mac=%%~l"
- (echo,网络名称: %%~j
- echo,适 配 器: %%~k
- echo,物理地址: %%~l)
- )
- for /f "tokens=1,* delims=_" %%m in ("%%~nxi") do (
- for %%o in ("dhcpipaddress","dhcpsubnetmask","dhcpdefaultgateway","dhcpnameserver","ipaddress","subnetmask","defaultgateway","nameserver","lease") do (
- reg.exe query "hklm\system\controlset001\services\tcpip\parameters\interfaces\%%n" /v "%%~o" >nul 2>nul&&(
- for /f "tokens=1,* delims=)" %%p in ('reg.exe query "hklm\system\controlset001\services\tcpip\parameters\interfaces\%%n" /v "%%~o" /z') do (
- if /i not "%%~nxp"=="%%n" for /f "tokens=1,* delims=, " %%r in ("%%q") do (
- if /i "%%~o"=="dhcpipaddress" (
- if not defined #_network_ipaddress set "#_network_ipaddress=%%r"
- echo,动态 IP 地址: %%r
- ) else if /i "%%~o"=="dhcpsubnetmask" (
- if not defined #_network_subnetmask set "#_network_subnetmask=%%r"
- echo,动态子网掩码: %%r
- ) else if /i "%%~o"=="dhcpdefaultgateway" (
- if not defined #_network_defaultgateway set "#_network_defaultgateway=%%r"
- echo,动态 网 关 : %%r
- ) else if /i "%%~o"=="dhcpnameserver" (
- if not defined #_network_nameserver_main set "#_network_nameserver_main=%%r"
- if not defined #_network_nameserver_spare set "#_network_nameserver_spare=%%s"
- echo,动态 dns服务: %%r,%%s
- ) else if /i "%%~o"=="ipaddress" (
- if not defined #_network_subnetmask set "#_network_subnetmask=%%r"
- echo,静态 IP 地址: %%r
- ) else if /i "%%~o"=="subnetmask" (
- if not defined #_network_subnetmask set "#_network_subnetmask=%%r"
- echo,静态子网掩码: %%r
- ) else if /i "%%~o"=="defaultgateway" (
- if not defined #_network_defaultgateway set "#_network_defaultgateway=%%r"
- echo,静态 网 关 : %%r
- ) else if /i "%%~o"=="nameserver" (
- if not defined #_network_nameserver_main set "#_network_nameserver_main=%%r"
- if not defined #_network_nameserver_spare set "#_network_nameserver_spare=%%s"
- echo,静态 dns服务: %%r,%%s
- ) else if /i "%%~o"=="lease" (
- if not defined #_network_lease set/a "#_network_lease=%%r"
- call echo,租约时间[秒]: %%#_network_lease%%
- )
- )
- )
- )
- )
- )
- )
- )
- set #_network_
- pause
复制代码
不改格式了代码太多了,自己改下吧 |