Use the bat file to create the HOSTS Quick Switch

Source: Internet
Author: User

Troubles in switching HOSTS files

IPV6 in schools is free of charge, but IPV6 does not need to go over the wall. However, some websites in IPV6 do not have a domain name even though they have an IPV6 IP address... Therefore, you can only access it by modifying the HOSTS file.
In addition, in IPV4, many Google services must modify the HOSTS file before they can be accessed...
Therefore, you need to switch the HOSTS file several times a day.
Is there any way to simplify this operation?

HOSTS switching software

I searched a lot of software on the Internet, but it was not very easy to use. I even had the urge to do it myself.

The logic of the design is basically as follows:

1. The software saves the IP addresses of many domain names, and each domain name has an IPV4 address and an IPV6 address (it will be automatically determined based on the network situation)
2. The software can save many solutions. Each click on a solution can perform a series of operations, such as: 1. Clear HOSTS; 2. Add XXX, for example: 1. do not modify the current HOSTS; 2. Disable XXX

In this way, you can freely control the HOSTS file.

Solution

Why is it so troublesome? Back up different HOSTS files. Which one is required to copy the files?
Still very troublesome? Just write the bat file directly? Although the above advanced functions cannot be implemented, they can also meet daily needs.

1. Create different HOSTS Solutions

Here I have created three new ones. One is empty, the other is IPV4, and the other is IPV6.

2. Start writing bat files

Copy codeThe Code is as follows: @ echo *****************
@ Echo * HOSTS switch *
@ Echo * 1 -- clear *
@ Echo * 2--IPV4 *
@ Echo * 3--IPV6 *
@ Echo *****************
@ Choice/c 123

If errorlevel 3 goto IPV6
If errorlevel 2 goto IPV4
If errorlevel 1 goto CLEAR

: CLEAR
Copy/y "C: \ Windows \ System32 \ drivers \ etc \ hosts. ics" C: \ Windows \ System32 \ drivers \ etc \ HOSTS"
Goto END

: IPV4
Copy/y "C: \ Windows \ System32 \ drivers \ etc \ hosts. ipv4" C: \ Windows \ System32 \ drivers \ etc \ HOSTS"
Goto END

: IPV6
Copy/y "C: \ Windows \ System32 \ drivers \ etc \ hosts. ipv6" C: \ Windows \ System32 \ drivers \ etc \ HOSTS"
Goto END

: END

This is easy to understand. Just write it as above.

3. Remaining Issues

There is another problem here. It is very dangerous to operate HOSTS (anti-virus software thinks so)
Therefore, a warning window is displayed. You can ignore it and add it to the whitelist.

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.