用批处理完成屏蔽恶意网址
发表时间:2023-05-30 来源:明辉站整理相关软件相关文章人气:
[摘要]@echo off @setlocal ENABLEDELAYEDEXPANSION title 可屏蔽网址的批处理. :begin mode con cols=50 li...
@echo off
@setlocal ENABLEDELAYEDEXPANSION
title 可屏蔽网址的批处理.
:begin
mode con cols=50 lines=56
echo *************************************************
echo *****************选择如下操作********************
echo.
echo.
echo ***************1.添加要屏蔽的网址****************
echo ***************2.删除已屏蔽的网址****************
echo ***************3.查找已屏蔽的网址****************
echo ***************4.退出****************************
echo.
copy %systemdrive%\WINDOWS\system32\drivers\etc\hosts %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt>nul
:chose
set /p enter=请你输入你的选择:
echo.
if /i "%enter%"=="1" goto add
if /i "%enter%"=="2" goto del
if /i "%enter%"=="3" goto check
if /i "%enter%"=="4" goto end
:add
set /p input=输入要添加的网址:
if /i "%input%"=="n" goto chose
echo 127.0.0.1 %input%>>%systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt
echo 成功添加屏蔽网址%input%
echo 请准确的输入或者按n跳到chose!
copy %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt %systemdrive%\WINDOWS\system32\drivers\etc\hosts>nul
pause
cls
goto begin
:del
echo ~_~你选择了删除操作切记务必最好输入完整的网址~_~
set /p del=输入要删除的网址:
if /i "%del%"=="n" goto chose
@for /f "tokens=* delims=" %%i in ('findstr /i /v /c:%del% %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt') do (
set var=%%i
echo !var!>>b.txt
)
copy b.txt %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt>nul
del b.txt
echo 操作完成
echo 请准确的输入或者按n跳到chose!
copy %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt %systemdrive%\WINDOWS\system32\drivers\etc\hosts>nul
pause
cls
goto begin
:check
for /f "tokens=2 delims= " %%i in ('findstr /i /c:"www" %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt') do (set var=%%i
echo !var!
)
for /f "tokens=2 delims= " %%i in ('findstr /i /c:"bbs" %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt') do (set var=%%i
echo !var!
)
copy %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt %systemdrive%\WINDOWS\system32\drivers\etc\hosts>nul
pause
goto begin
:end
copy %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt %systemdrive%\WINDOWS\system32\drivers\etc\hosts>nul
del %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt
exit
上面是电脑上网安全的一些基础常识,学习了安全知识,几乎可以让你免费电脑中毒的烦扰。