显示ip的批处理
答案:2 悬赏:20 手机版
解决时间 2021-03-02 03:26
- 提问者网友:沉默菋噵
- 2021-03-01 20:52
很简单 不是网上的那段代码 而是我先要个 运行后 里面只显示 您的ip是:xxx.xxx.xxx.xxx 就这样 谁会不?
最佳答案
- 五星知识达人网友:洒脱疯子
- 2021-03-01 22:17
IP.bat 代码:@echo off
::调用:
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%
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
::调用:
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%
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
全部回答
- 1楼网友:时间的尘埃
- 2021-03-01 23:53
bat设置“本地连接”的ip地址。
把以下代码复制粘贴到记事本,修改里面的连接名称、ip、子网掩码、网关、dns,保存为“ip.bat”.
(你提供的dns不正确)
@echo off
echo 正在设置ip,子网,请稍候......
netsh int ip set add name="本地连接" static 172.16.101.12 255.255.255.0 172.16.101.1
echo.
echo 正在设置dns,请稍候.....
netsh int ip set dns name="本地连接" source=static 221.12.157???
netsh int ip add dns name="本地连接" 221.12.157??? index=2
echo 设置完毕!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯