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