DOS 脚本
向 hosts 文件添加本地回环记录
向 hosts 文件添加 127.0.0.1 localhost 和 ::1 localhost两条记录,并保证不重复添加
@echo off
:host1
set sHost=127.0.0.1
set sDomain=localhost
FOR /F "eol=# tokens=1,2 delims= " %%i in (C:\Windows\system32\drivers\etc\hosts) do if "%%i"=="%sHost%" if "%%j"=="%sDomain%" goto host2
@ECHO %sHost% %sDomain% >>C:\Windows\System32\drivers\etc\hosts
:host2
set sHost=::1
set sDomain=localhost
FOR /F "eol=# tokens=1,2 delims= " %%i in (C:\Windows\system32\drivers\etc\hosts) do if "%%i"=="%sHost%" if "%%j"=="%sDomain%" goto end
@ECHO %sHost% %sDomain% >>C:\Windows\System32\drivers\etc\hosts
:end
ipconfig /flushdns
@ECHO "按任意键退出"
@pause
@exit在文件管理器添加派盘
最后更新于