用bat更改hosts文件批处理

原文地址: https://www.jb51.net/article/51902.htm

@echo off
echo "请注意你的杀毒软件提示,一定要允许"
@echo  ########################################
@xcopy C:\Windows\system32\drivers\etc\hosts C:\Windows\system32\drivers\etc\hosts.bak\ /d /c /i /y 
@echo  ########################################
@echo  hosts文件备份完毕,开始修改hosts文件
@echo 
@echo 117.79.149.116 search.b2b.cn >>C:\Windows\System32\drivers\etc\hosts
@echo 117.79.149.116 news.search.b2b.cn >>C:\Windows\System32\drivers\etc\hosts
echo   "hosts文件修改完成"
@ipconfig /flushdns
@echo   "刷新DNS完成"

echo  hosts文件修改完毕,按任意键恢复系统原始状态
@echo
@echo  ########################################
@pause > nul
@copy C:\Windows\System32\drivers\etc\hosts.bak\hosts C:\Windows\System32\drivers\etc\hosts /y
@echo 
@echo off
echo  hosts文件恢复完毕,按任意键退出
@echo 
@pause > nul
@exit
posted @ 2021-07-06 11:18  林宇风  阅读(836)  评论(0编辑  收藏  举报