Batch backs up the current hosts file and reverts to the initial state

Source: Internet
Author: User

Product Department testing products need to constantly modify the hosts, many new people will not, write a batch processing, save as Bat format, or compiled into EXE format, run can. The code is as follows:


@echo  offcolor 0Aecho                                         Description:echo.echo  Please exit 360 and other security class software!!! Then proceed to the next steps. echo.echo  back up the current hosts file to the "Hosts file backup" folder of the partition you selected, or restore the Hosts file to its original state. Echo.echo.:menuecho 1. Back up the current Hosts file echo 2. Restore the Hosts file to the initial state echo 3. Exit the program echo.echo  Select the action you want to take: inputset /p pd=if  "%pd%" = = "1"  goto backupif  "%pd%" = = "2"  goto  recoveryif  "%pd%" = = "3"  goto quitecho  input error, please re-enter goto input:backupecho  Please enter the partition letter you want to save, for example: dset /p desk=set t=%date:~,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%-%time:~3,2%-% Time:~6,2%md %desk%:\hosts file backup \%t%copy c:\windows\system32\drivers\etc\hosts %desk%:\hosts file backup \ %t%echo hosts files have been backed up to the%desk%:\hosts file backup \%t%\ directory start %desk%:\hosts file backup \%t%:recoveryecho # copyright  (c)  1993-2009 Microsoft Corp.>hostsecho #>> Hostsecho # this is a sample hosts file used by microsoft  TCP/IP for Windows.>>hostsecho #>>hostsecho # This file  Contains the mappings of ip addresses to host names. each>> Hostsecho # entry should be kept on an individual line. the  ip address should>>hostsecho # be placed in the first  column followed by the corresponding host name.>>hostsecho #  The IP address and the host name should be separated  By at least one>>hostsecho # space.>>hostsecho #>>hostsecho  # Additionally, comments  (Such as these)  may be inserted on individual>> Hostsecho # lines or following the machine name denoted by a   ' # '  symbol.>>hostsecho #>>hostsecho # for example:>>hostsecho  #>>hostsecho #      102.54.94.97      Rhino.acme.com          # source server>> Hostsecho #       38.25.63.10     x.acme.com               # x client  Host>>hostsecho.>>hostsecho # localhost name resolution is handled  within DNS itself.>>hostsecho #    127.0.0.1        localhost>>hostsecho #    ::1              localhost>>hostsecho.>>hostscopy hosts c:\windows\system32 \drivers\etcdel hostsexit:quitexit


This article is from the "Hello3389 blog" blog, make sure to keep this source http://hello3389.blog.51cto.com/1171990/1599322

Batch backs up the current hosts file and reverts to the initial state

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.