To replace the Hosts file in a Windows system by using batch processing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.