attrib -R C:\WINDOWS\system32\drivers\etc\hosts
@echo 192.168.0.110 xx.xxx.cn >>C:\WINDOWS\system32\drivers\etc\hosts
attrib +R C:\WINDOWS\system32\drivers\etc\hosts
使用使用管理员权限运行 ,attrib -R
是移除文件的可读属性
host 文件推荐平时都是给只读权限,防止乱七八糟的软件去修改host
windows+R
输入cmd 回车
方式一
cd C:WindowsSystem32driversetc echo ### >表示覆盖,>>表示追加 #### >hosts echo 127.0.0.1 aa 127.0.0.1 bb>>hosts
方式二
桌面新建一个hosts文件,填写好内容
方式三
因为我host文件在桌面,cmd默认打开为在c盘执行所以不用切盘符,pause表示不关闭cmd窗口
cd C:UsersAdministrator桌面 && copy hosts C:WindowsSystem32driversetchosts /y && pause
如果你的hosts文件在D:yourfile
D: && cd yourfile && copy hosts C:WindowsSystem32driversetchosts /y && pause
将如上代码直接放入bat文件执行,然后双击bat文件即可,管理方便