http://hi.baidu.com/wangbaohua3/blog/item/46f7d650da41f4113b29355e.html
@echo off&setlocal enabledelayedexpansion
set cc=C:\WINDOWS\system32\drivers\etc\hosts
for /f "tokens=2" %%i in (%cc%) do (
if "%%i"=="Copyright" (for /f "skip=17 delims=#" %%i in ('type %cc%^&del %cc%') do echo.%%i>>%cc%) else (for /f
"delims=#" %%i in ('type %cc%^&del %cc%') do echo.%%i>>%cc%))&(goto :m)
:m
echo #已去除
echo 追加HOSTS条目
set sthosts=67.132.51.1 srv1
for /f "tokens=1*" %%a in ('echo %sthosts%') do findstr /e /b /r /c:" *%%a *%%b *" %cc%>nul||echo %sthosts%>>%cc%
最后一句就行了