显示网络配置的批处理文件
程序员文章站
2022-07-04 17:19:59
显示网络配置.bat复制代码 代码如下:@echo off :: 代码编写:3742668 代码修订:namejm www.cn-d...
显示网络配置.bat
@echo off
:: 代码编写:3742668 代码修订:namejm www.cn-dos.net
::调用格式:
call :select "ip address" "ip"
call :select "physical address" "mac"
call :select "default gateway" "gateway"
call :select "dns servers" "dns"
call :select "description" "netcard"
:: 演示效果
echo ip:%ip%
echo mac:%mac%
echo dns:%dns%
echo gateway:%gateway%
echo netcard:%netcard%
pause>nul
goto :eof
::**************************************************************
:: 解析ipconfig命令输出通用函数
::**************************************************************
:select
for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not "!%~2!" == "" set "%~2=%%i"
goto :eof
复制代码 代码如下:
@echo off
:: 代码编写:3742668 代码修订:namejm www.cn-dos.net
::调用格式:
call :select "ip address" "ip"
call :select "physical address" "mac"
call :select "default gateway" "gateway"
call :select "dns servers" "dns"
call :select "description" "netcard"
:: 演示效果
echo ip:%ip%
echo mac:%mac%
echo dns:%dns%
echo gateway:%gateway%
echo netcard:%netcard%
pause>nul
goto :eof
::**************************************************************
:: 解析ipconfig命令输出通用函数
::**************************************************************
:select
for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i /c:%1') do if not "!%~2!" == "" set "%~2=%%i"
goto :eof
下一篇: 查找最新的文件的批处理bat文件