批量快速一键修改IP,掩码,网关,以及dns代码-创新互联

保存到bat

创新互联建站自2013年创立以来,是专业互联网技术服务公司,拥有项目成都网站制作、成都做网站、外贸营销网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元松阳做网站,已为上家服务,为松阳各地企业和个人服务,联系电话:18980820575
@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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享文章:批量快速一键修改IP,掩码,网关,以及dns代码-创新互联
文章起源:http://myzitong.com/article/hscjh.html