可能部分人不知道原理,
我先简单的说下
大家可以打开hosts文件看看(在C:\WINDOWS\system32\drivers\etc里面),如下- # Copyright (c) 1993-1999 Microsoft Corp.
- #
- # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
- #
- # This file contains the mappings of IP addresses to host names. Each
- # entry should be kept on an individual line. The IP address should
- # be placed in the first column followed by the corresponding host name.
- # The IP address and the host name should be separated by at least one
- # space.
- #
- # Additionally, comments (such as these) may be inserted on individual
- # lines or following the machine name denoted by a '#' symbol.
- #
- # For example:
- #
- # 102.54.94.97 rhino.acme.com # source server
- # 38.25.63.10 x.acme.com # x client host
-
- 127.0.0.1 localhost
复制代码 只要在最后一行后面加上
127.0.0.1 你想屏蔽的网址 (注意:有7个空格)
就打不开了(对原理感兴趣的自己BAIDU下)
下面是我写的- @echo off&setlocal enabledelayedexpansion
- :kaishi
- echo.
- echo.
- echo.
- echo.
- echo 添加网址过滤请输入1;解除网址屏蔽请输入2;退出请按0;
- set /p scanf=
- if !scanf!==1 goto :pb else (
- if !scanf!==2 goto:jc else
- goto :end)
- :pb
- set /p str=请输入你想屏蔽的网址:
- echo 127.0.0.1 !str!>>C:\WINDOWS\system32\drivers\etc\hosts
- echo 网址!str!已经成功屏蔽!
- pause & cls & goto :kaishi
-
- :jc
- set /p str=请输入你想解除屏蔽的网址:
- for /f "delims=" %%a in (C:\WINDOWS\system32\drivers\etc\hosts) do echo %%a | findstr /v "!str!">>C:\WINDOWS\system32\drivers\etc\hosts1
- del C:\WINDOWS\system32\drivers\etc\hosts /q
- ren C:\WINDOWS\system32\drivers\etc\hosts1 hosts
- pause & cls & goto :kaishi
-
- :end
- exit
复制代码
[ 本帖最后由 novaa 于 2007-11-25 18:58 编辑 ] |