2023-05-12 开启多语言插件支持……

bat简单命令 实现批量更改系统host文件

hosts 苏 demo 3259℃ 0评论

cd /d %windir%\system32\drivers\etc
del hosts.bak //删除原来备份文件
ren hosts hosts.bak //备份现在host
for /f “eol=# tokens=1,2” %%i in (hosts.bak) do call :checkvalue %%i %%j
goto end
:checkvalue
echo %2 | find /i “qa.phpunion.net” //寻找制定记录删除
if %errorlevel%==1 (echo %1 %2 >>hosts)
:end

type C:\WINDOWS\system32\drivers\etc\hosts
type C:\WINDOWS\system32\drivers\etc\hosts | find “qa.phpunion.net” && goto yes
@echo. >>C:\Windows\System32\Drivers\etc\hosts
::echo 192.168.1.124 new.phpunion.net >> “”
echo 192.168.1.125 new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.125 css.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.125 js.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.126 passport.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.126 res.passport.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.126 ucenter.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.125 jpg.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.1.125 img.new.phpunion.net >> C:\WINDOWS\system32\drivers\etc\hosts

将代码拷贝,保存为.bat格式的文件,即可运行哦。注意事项,win7/8下需要设置host文件,当前登陆系统用户可以读写,以及使用管理员身份来运行 此文件。

如果 您感觉本文对您有帮助,请帮忙点击文章右侧的广告位,支持一下博主。谢谢!

打赏

转载请注明:苏demo的别样人生 » bat简单命令 实现批量更改系统host文件

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)