@echo off set stHosts=127.0.0.1 www.XXX.com FOR /F "eol=# tokens=1 delims=" %%i in (%SystemRoot%system32driversetchosts) do if "%stHosts%"=="%%i" exit echo %stHosts%>> %SystemRoot%system32driversetchosts
保存文件为*.bat,放到“启动”文件夹内(C:ProgramDataMicrosoftWindowsStart MenuProgramsStartUp)