批量快速一键修改IP,掩码,网关,以及dns代码
生活随笔
收集整理的這篇文章主要介紹了
批量快速一键修改IP,掩码,网关,以及dns代码
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
保存到bat
@echo off color 0E title 大橘子網(wǎng)絡(luò)維護(hù)系統(tǒng) echo ************************************************************************************************** echo * ┏┓ ┏┓+ + echo * ┏┛┻━━━┛┻┓ + + echo * ┃ ┃ echo * ┃ ━ ┃ ++ + + + echo * ████━████ ┃+ echo * ┃ ┃ + echo * ┃ ┻ ┃ echo * ┃ ┃ + + 大橘子網(wǎng)絡(luò)維護(hù)腳本 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>nulrem echo ........................new address:%ip%........................................ echo ................The ip address is set successfully. Press any key to exit. ........................................ pause>nulipconfig/all這是我第一次寫的,后來發(fā)現(xiàn)還是有些不太智能。
于是,我在空閑之余又對(duì)其進(jìn)行了一下改進(jìn)
@echo off color 0E title 大橘子網(wǎng)絡(luò)維護(hù)系統(tǒng) By:大橘子 echo ************************************************************************************************** echo * ┏┓ ┏┓+ + echo * ┏┛┻━━━┛┻┓ + + echo * ┃ ┃ echo * ┃ ━ ┃ ++ + + + echo * ████━████ ┃+ echo * ┃ ┃ + echo * ┃ ┻ ┃ echo * ┃ ┃ + + 大橘子網(wǎng)絡(luò)維護(hù)腳本 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>nulset 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 * ┃ ┃ + + 大橘子網(wǎng)絡(luò)維護(hù)腳本 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>nulping /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 strpause>nul ipconfig/all轉(zhuǎn)載于:https://blog.51cto.com/14224877/2358880
總結(jié)
以上是生活随笔為你收集整理的批量快速一键修改IP,掩码,网关,以及dns代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python持续更新的新特性
- 下一篇: mysql之调优概论