用批處理完成屏蔽惡意網(wǎng)址
發(fā)表時(shí)間:2023-05-30 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]@echo off @setlocal ENABLEDELAYEDEXPANSION title 可屏蔽網(wǎng)址的批處理. :begin mode con cols=50 li...
@echo off
@setlocal ENABLEDELAYEDEXPANSION
title 可屏蔽網(wǎng)址的批處理.
:begin
mode con cols=50 lines=56
echo *************************************************
echo *****************選擇如下操作********************
echo.
echo.
echo ***************1.添加要屏蔽的網(wǎng)址****************
echo ***************2.刪除已屏蔽的網(wǎng)址****************
echo ***************3.查找已屏蔽的網(wǎng)址****************
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=輸入要添加的網(wǎng)址:
if /i "%input%"=="n" goto chose
echo 127.0.0.1 %input%>>%systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt
echo 成功添加屏蔽網(wǎng)址%input%
echo 請準(zhǔn)確的輸入或者按n跳到chose!
copy %systemdrive%\WINDOWS\system32\drivers\etc\hosts.txt %systemdrive%\WINDOWS\system32\drivers\etc\hosts>nul
pause
cls
goto begin
:del
echo ~_~你選擇了刪除操作切記務(wù)必最好輸入完整的網(wǎng)址~_~
set /p del=輸入要?jiǎng)h除的網(wǎng)址:
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 請準(zhǔn)確的輸入或者按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
上面是電腦上網(wǎng)安全的一些基礎(chǔ)常識(shí),學(xué)習(xí)了安全知識(shí),幾乎可以讓你免費(fèi)電腦中毒的煩擾。