1.新建文件host.bat
2.代码
@echo off cd.>C:\Windows\System32\drivers\etc\hosts echo .本地环境 .线上测试环境 set /p user_input=请输入1/,切换Hosts文件内容: if %user_input% equ (
echo 127.0.0.1 www.xxx.com
echo 127.0.0.1 wap.xxx.com
echo 127.0.0.1 m.xxx.com
)>>C:\Windows\System32\drivers\etc\hosts if %user_input% equ (
echo 192.168.0.221 www.xxx.com
echo 192.168.0.221 wap.xxx.com
)>>C:\Windows\System32\drivers\etc\hosts echo 切换成功 pause