windows cmd 一行代码修改hosts文件内容

    xiaoxiao2023-10-18  161

    windows+R

    输入cmd 回车

    方式一

    cd C:\Windows\System32\drivers\etc echo ### >表示覆盖,>>表示追加 #### >hosts echo 127.0.0.1 aa 127.0.0.1 bb>>hosts

    方式二

    桌面新建一个hosts文件,填写好内容

    cd 桌面 copy hosts C:\Windows\System32\drivers\etc\hosts /y ## /y表示自动确认覆盖原文件否则要手动输入y进行确认

    方式三

    因为我host文件在桌面,cmd默认打开为在c盘执行所以不用切盘符,pause表示不关闭cmd窗口

    cd C:\Users\Administrator\桌面 && copy hosts C:\Windows\System32\drivers\etc\hosts /y && pause

    如果你的hosts文件在D:\yourfile

    D: && cd yourfile && copy hosts C:\Windows\System32\drivers\etc\hosts /y && pause

    将如上代码直接放入bat文件执行,然后双击bat文件即可,管理方便

    如果开了360等杀毒软件会有如下提示

    最新回复(0)