CHCP 936 >nul
@echo off
Mode con lines=30 cols=60
%1 Mshta vbscript:createobject ("Shell.Application"). ShellExecute ("cmd.exe", "/C%~s0::", "", "RunAs", 1) (Window.close) &&exit
cd/d "%~dp0"
: Main
Cls
Color 0a
echo. Warning: Execute this command and your hosts will be automatically replaced by overrides!
echo. If your original hosts have their own modified information, please manually modify it yourself!
Echo.
Echo.
echo.2017 Permanent update Address:
Echo.https://laod.cn/hosts/2017-google-hosts.html
Color 0a
Echo.-----------------------------------------------------------
echo. Please choose to use:
Echo.
Echo. 1. Use the wall-through hosts (i.e. enter 1 below)
Echo.
Echo. 2. Restore the initial hosts (i.e. enter 2 below)
Echo.-----------------------------------------------------------
If exist "%systemroot%\system32\choice.exe" goto Win7choice
set/p choice= Please enter a number and press ENTER to confirm:
Echo.
If%choice%==1 Goto host DNS
If%choice%==2 goto CL
Cls
"Set Choice="
echo you entered the wrong, please re-select.
Ping 127.0.1-n "2" >nul
Goto Main
: Win7choice
CHOICE/C 12/n/M "Please enter the corresponding number:"
if errorlevel 2 goto CL
if errorlevel 1 goto host DNS
Cls
Goto Main
: Host DNS
Cls
Color 0a
copy/y "hosts" "%systemroot%\system32\drivers\etc\hosts"
Ipconfig/flushdns
Echo.-----------------------------------------------------------
Echo.
echo Assen Congratulations, overwrite the local hosts and refresh the local DNS resolution cache successfully!
Echo.
Echo now to open Google, Twitter, Facebook, Gmail, Google academic bar!
Echo.
echo. Google these sites remember to use HTTPS for encrypted access!
Echo.
echo. i.e.: https://www.google.com
Echo.
echo. Or: HTTPS://WWW.GOOGLE.COM/NCR
Echo. Https://www.google.com.hk/ncr
Echo.
Goto END
: CL
Cls
Color 2f
@echo 127.0.0.1 localhost >%systemroot%\system32\drivers\etc\hosts
Echo Congratulations, the hosts resumed their initial success!
Echo.
Goto END
: End
echo Please press any key to exit.
@Pause >nul
To replace the Hosts file in a Windows system by using batch processing