Get the App
SLTechnology News&Howtos  ›  Servers  › 

Change the batch processing of hosts files with bat

Shulou Source: shulou.com Published: 2022-06-02 17:29:02 09月22日 Update

Add mapping between ip and domain name

@ ECHO offECHO "XXXXXX Technology Co., Ltd."ECHO" Please pay attention to your antivirus software tips Be sure to allow "@ ECHO # # @ xcopy C:\ Windows\ system32\ drivers\ etc\ hosts C:\ Windows\ system32\ drivers\ etc\ hosts.bak\ / d / c / I / y@ECHO # # @ ECHO hosts file backup completed Start modifying hosts file @ ECHO@ECHO 10.0.0.2 gitlab.a.com > > C:\ Windows\ System32\ drivers\ etc\ hosts@ECHO 10.0.0.3 gitlab.b.com > > C:\ Windows\ System32\ drivers\ etc\ hosts@ECHO 10.0.0.4 gitlab.c.com > > C:\ Windows\ System32\ drivers\ etc\ hostsECHO "hosts file modification completed" @ ipconfig / flushdns@ECHO "refresh DNS complete" @ ECHO "press any key to exit" @ pause > nul@exit "

Restore backed up hosts files

When the echo hosts file has been modified, press any key to restore the original state of the system @ echo@echo # # @ pause > nul@copy C:\ Windows\ System32\ drivers\ etc\ hosts.bak\ hosts C:\ Windows\ System32\ drivers\ etc\ hosts / y@echo@echo offecho hosts file, press any key to exit @ echo@pause > nul@exit

What's wrong with the hint? Please check whether the environment variable or encoding format is ANSI

Tags: File backup prompt original company variable domain name technology limited limited antivirus software format status environment system code see software Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL NVidia Shulou Technology Huawei MariaDB