当前位置:DOS资源站资料中心批处理教程 → 批处理写的网站屏蔽的工具

批处理写的网站屏蔽的工具

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-4-18 16:29:22

代码:
@echo off&title DOS资源站 www.cmdos.net
:start
cls
title 网站屏蔽工具
echo.&echo.
echo                       网站屏蔽工具 制作ByX林 07.9.29
echo                               xlqlin@sina.com
echo.&echo.
echo   ........................................................................
echo   .      1.添加屏蔽网站          2.取消屏蔽网站         0.退出           .
echo   ........................................................................

for /l %%i in (1,1,2) do echo.
set /p aa=请选择:
if /i %aa%==1 goto :add
if /i %aa%==0 exit
if /i %aa%==2 (goto :clear) else (goto :start)
:add
echo 使用说明:如要屏蔽百度则输入www.baidu.com然后回车即可。
for /l %%i in (1,1,2) do echo.
set /p a=请输入要屏蔽的网站:
echo 0.0.0.0 %a%>>%windir%\system32\drivers\etc\hosts
echo.&echo.
echo                           %a%已经屏蔽
ping /n 3 127.1>nul
goto start
:clear
for /l %%i in (1,1,2) do echo.
echo 使用说明:如要取消屏蔽百度则输入www.baidu.com然后回车即可。
for /l %%i in (1,1,2) do echo.
set /p b=请输入要取消屏蔽的网站:
for /f "tokens=* delims=" %%i in (%windir%\system32\drivers\etc\hosts) do (
   if /I "%%i"=="0.0.0.0 %b% " (set "tmp=") else echo %%i>>%windir%\system32\drivers\etc\host
)
del %windir%\system32\drivers\etc\hosts
ren %windir%\system32\drivers\etc\host hosts
for /l %%i in (1,1,2) do echo.
echo                          已经取消屏蔽%b%
ping /n 3 127.1>nul
goto start