批量快速一键修改IP,掩码,网关,以及dns代码

发布时间:2020-07-23 16:28:03 作者:wx5c7cf1eb66cea
来源:网络 阅读:971

保存到bat

@echo off
color 0E
title 大橘子网络维护系统
echo **************************************************************************************************
echo *        ┏┓   ┏┓+ +
echo *       ┏┛┻━━━┛┻┓ + +
echo *       ┃       ┃
echo *       ┃   ━   ┃ ++ + + +
echo *       ████━████ ┃+
echo *       ┃       ┃ +
echo *       ┃   ┻   ┃
echo *       ┃       ┃ + +             大橘子网络维护脚本
echo *       ┗━┓   ┏━┛
echo *         ┃   ┃
echo *         ┃   ┃ + + + +
echo *         ┃   ┃    Code is far away from bug with the animal protecting
echo *         ┃   ┃ +     
echo *         ┃   ┃
echo *         ┃   ┃  +         神兽保佑,代码无bug
echo *         ┃    ┗━━━┓ + +
echo *         ┃        ┣┓
echo *         ┃        ┏┛
echo *         ┗┓┓┏━┳┓┏┛ + + + +
echo *          ┃┫┫ ┃┫┫
echo *          ┗┻┛ ┗┻┛+ + + +
echo **************************************************************************************************
echo **************************************************************************************************

@for /f "tokens=1,2* delims=:" %%a in ('ipconfig ^|findstr "IP Address"') do set ip=%%b
echo ............................address:%ip%........................................

pause>nul

@set /p c=:

@netsh interface ipv4 set address 本地连接 static 192.168.23.%c% 255.255.252.0 192.168.23.1 >nul 2>nul

@netsh interface ipv4 set dns 本地连接 static 202.96.128.86 >nul 2>nul

@netsh interface ipv4 add dns 本地连接 202.96.128.166 index=2 >nul 2>nul

rem echo ........................new address:%ip%........................................
echo ................The ip address is set successfully. Press any key to exit. ........................................
pause>nul

ipconfig/all

这是我第一次写的,后来发现还是有些不太智能。

于是,我在空闲之余又对其进行了一下改进

@echo off
color 0E
title 大橘子网络维护系统 By:大橘子
echo **************************************************************************************************
echo *        ┏┓   ┏┓+ +
echo *       ┏┛┻━━━┛┻┓ + +
echo *       ┃       ┃
echo *       ┃   ━   ┃ ++ + + +
echo *       ████━████ ┃+
echo *       ┃       ┃ +
echo *       ┃   ┻   ┃
echo *       ┃       ┃ + +             大橘子网络维护脚本
echo *       ┗━┓   ┏━┛
echo *         ┃   ┃
echo *         ┃   ┃ + + + +
echo *         ┃   ┃    Code is far away from bug with the animal protecting
echo *         ┃   ┃ +     
echo *         ┃   ┃
echo *         ┃   ┃  +         神兽保佑,代码无bug
echo *         ┃    ┗━━━┓ + +
echo *         ┃        ┣┓
echo *         ┃        ┏┛
echo *         ┗┓┓┏━┳┓┏┛ + + + +
echo *          ┃┫┫ ┃┫┫
echo *          ┗┻┛ ┗┻┛+ + + +
echo **************************************************************************************************
echo **************************************************************************************************

ping /n 2 127.1>nul

set Num=100
set N=0
:str
set /a n=%n%+1
if "%n%"=="%Num%" goto end

@for /f "tokens=1,2* delims=:" %%a in ('ipconfig ^|findstr "IP Address"') do set ip=%%b
echo ............................address:%ip%........................................

rem echo %ip:~0,11%
set trunIp=%ip:~0,11%
rem echo %trunIp%

if 192.168.23==%trunIp% (ping www.baidu.com -t -n 10
echo ip set is Good!
echo Please press Enter to exit!
pause>nul
exit) else (@echo ......................................IP In settings........................................)     
echo **************************************************************************************************
echo *        ┏┓   ┏┓+ +
echo *       ┏┛┻━━━┛┻┓ + +
echo *       ┃       ┃
echo *       ┃   ━   ┃ ++ + + +
echo *       ████━████ ┃+
echo *       ┃       ┃ +
echo *       ┃   ┻   ┃
echo *       ┃       ┃ + +             大橘子网络维护脚本
echo *       ┗━┓   ┏━┛
echo *         ┃   ┃
echo *         ┃   ┃ + + + +
echo *         ┃   ┃    Code is far away from bug with the animal protecting
echo *         ┃   ┃ +     
echo *         ┃   ┃
echo *         ┃   ┃  +         神兽保佑,代码无bug
echo *         ┃    ┗━━━┓ + +
echo *         ┃        ┣┓
echo *         ┃        ┏┛
echo *         ┗┓┓┏━┳┓┏┛ + + + +
echo *          ┃┫┫ ┃┫┫
echo *          ┗┻┛ ┗┻┛+ + + +
echo **************************************************************************************************
echo **************************************************************************************************

pause>nul

@set /p c=:

@netsh interface ipv4 set address 本地连接 static 192.168.23.%c% 255.255.252.0 192.168.23.1 >nul 2>nul

@netsh interface ipv4 set dns 本地连接 static 202.96.128.86 >nul 2>nul

@netsh interface ipv4 add dns 本地连接 202.96.128.166 index=2 >nul 2>nul

ping /n 5 127.1>nul

@for /f "tokens=1,2* delims=:" %%a in ('ipconfig ^|findstr "IP Address"') do set ip=%%b
echo ........................new address:%ip%........................................

echo ................The ip address is set successfully. Press any key to exit. .........................................

goto str

pause>nul
ipconfig/all
推荐阅读:
  1. 子网掩码、广播地址、DNS和网关
  2. IP网关,子网掩码,广播地址查询

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

网络/运维 一键修改

上一篇:电脑是32位系统可不可以装64位eclipse

下一篇:嵌入式开发/调试辅助工具

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》