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
如果 您感觉本文对您有帮助,请帮忙点击文章右侧的广告位,支持一下博主。谢谢!
转载请注明:苏demo的别样人生 » bat简单命令 实现批量更改系统host文件