:: Create a clean default hosts file ( echo # Copyright (c) 1993-2009 Microsoft Corp. echo # echo # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. echo # echo # This file contains the mappings of IP addresses to host names. Each echo # entry should be kept on an individual line. The IP address should echo # be placed in the first column followed by the corresponding host name. echo # The IP address and the host name should be separated by at least one echo # space. echo # echo # Additionally, comments (such as these) may be inserted on individual echo # lines or following the machine name denoted by a '#' symbol. echo # echo # For example: echo # echo # 102.54.94.97 rhino.acme.com # source server echo # 38.25.63.10 x.acme.com # x client host echo # echo # localhost name resolution is handled within DNS itself. echo # 127.0.0.1 localhost echo # ::1 localhost echo 127.0.0.1 localhost echo ::1 localhost ) > "%hosts%"
:: Check if already blocked findstr /i /c:"%loopback% %site%" "%hosts%" >nul if %errorlevel% equ 0 ( echo [INFO] %site% is already blocked. pause goto menu )
:restore cls echo ---------------------------------------------- echo Restore Default Hosts File echo ---------------------------------------------- echo. echo WARNING: This will remove ALL custom entries. echo. set /p confirm="Are you sure? Type YES to continue: " if /i not "%confirm%"=="YES" ( echo Operation cancelled. pause goto menu ) easeus hosts blocker.bat
:: Add to hosts file echo %loopback% %site% >> "%hosts%" echo. echo [SUCCESS] %site% has been blocked. echo [INFO] Flushing DNS cache... ipconfig /flushdns >nul pause goto menu
echo. echo [SUCCESS] %site% has been unblocked (if it was blocked). echo [INFO] Flushing DNS cache... ipconfig /flushdns >nul pause goto menu :: Create a clean default hosts file (
:: Define hosts file path set hosts=%windir%\System32\drivers\etc\hosts set loopback=127.0.0.1
:show cls echo ---------------------------------------------- echo Currently Blocked Websites echo ---------------------------------------------- echo. echo (Lines starting with %loopback% in hosts file) echo ---------------------------------------------- findstr /i /c:"%loopback%" "%hosts%" | findstr /v "#" echo ---------------------------------------------- echo. pause goto menu Each echo # entry should be kept on an individual line
@echo off title EaseUS Style Hosts Blocker color 0E echo ============================================== echo EaseUS Hosts Blocker Tool echo ============================================== echo. :: Check for Administrator privileges net session >nul 2>&1 if %errorLevel% neq 0 ( echo [ERROR] Please run this script as Administrator. echo Right-click the file and select "Run as administrator". pause exit /b 1 )