@echo off echo "请注意你的杀毒软件提示,一定要允许" @echo ######################################## @xcopy C:Windowssystem32driversetchosts C:Windowssystem32driversetchosts.bak /d /c /i /y @echo ######################################## @echo hosts文件备份完毕,开始修改hosts文件 @echo @echo 117.79.149.116 search.b2b.cn >>C:WindowsSystem32driversetchosts @echo 117.79.149.116 news.search.b2b.cn >>C:WindowsSystem32driversetchosts echo "hosts文件修改完成" @ipconfig /flushdns @echo "刷新DNS完成" echo hosts文件修改完毕,按任意键恢复系统原始状态 @echo @echo ######################################## @pause > nul @copy C:WindowsSystem32driversetchosts.bakhosts C:WindowsSystem32driversetchosts /y @echo @echo off echo hosts文件恢复完毕,按任意键退出 @echo @pause > nul @exit搭建本地的测试环境
@echo off echo 搭建本地测试环境 echo. c: cd if not exist lmhy-testcon md lmhy-test if exist lmhy-testhosts.bak goto backup_exists echo 正在创建备份…… cd windowssystem32driversetc copy /y hosts lmhy-testhosts.bak > null echo 完成! echo. goto backup_start :backup_exists echo 备份文件已经存在,无需备份。 echo. :backup_start echo 正在写入测试数据…… echo 127.0.0.1 localhost > hosts echo 192.168.1.170 lmhy.com >> hosts echo 192.168.3.170 www.lmhy.com >> hosts echo 192.168.3.170 php.lmhy.com >> hosts echo 192.168.3.170 test.lmhy.com >> hosts echo 完成! echo. echo 建立 lmhy 本地测试环境完成。按任意键退出…… pause > null卸载本地测试环境
@echo off echo 卸载本地测试环境 echo. c: cd if not exist lmhy-testhosts.bak goto backup_not_exists echo 正在还原备份…… copy /y lmhy-testhosts.bak windowssystem32driversetc > null cd windowssystem32driversetc if exist hosts del /q hosts ren hosts.bak hosts echo 完成! echo. echo 正在移除备份…… cd rmdir /s/q lmhy-test echo 完成! echo. goto backup_done :backup_not_exists echo 备份文件不存在,无法恢复。批处理利用HOSTS文件(屏蔽,加速)网站的代码
@echo off&setlocal&cls echo/&echo&echo=&echo]&echo[&echo+ :start set/p a=选择模式(1:屏蔽网站 2:加速访问 3:删除被屏蔽的网站 4:退出): if not defined a goto start if %a% equ 1 (echo/&goto a) if %a% equ 2 (echo/&goto b) if %a% equ 3 (echo/&goto c) if %a% equ 4 (cls&goto :eof) cls echo 输入错误,按任意键重新开始... ... pause>nul echo/&echo&echo=&echo]&echo[&echo+ goto start :a set/p b= 输入要屏蔽的网站地址 (如:www.baidu.com): >>%systemroot%system32driversetchosts echo 0.0.0.0 %b% echo ********设置完成******** goto :eof :b set/p b= 输入要加速访问的主机IP (如:192.168.1.6 ): set/p bb= 输入要加速访问的主机域名(如:www.baidu.com): >>%systemroot%system32driversetchosts echo %b% %bb% echo ********设置完成******** goto :eof :c set/p b= 输入曾经屏蔽过的网站地址: pushd %systemroot%system32driversetc >nul findstr /i "<%b%>">hosts.pp findstr /vi "<%b%>" 欢迎分享,转载请注明来源:内存溢出
评论列表(0条)