@echo 127.0.0.1 baidu.com >>c:\windows\system32\drivers\etc\hosts
This is to change one line of writing.
If you want to change another line, write:
Copy Code code as follows:
@echo. >>c:\windows\system32\drivers\etc\hosts
@echo 127.0.0.1 baidu.com >>c:\windows\system32\drivers\etc\hosts
@echo 192.168.4.201 Ibmrac1 >>c:\windows\system32\drivers\etc\hosts
@echo 192.168.4.202 Ibmrac2 >>c:\windows\system32\drivers\etc\hosts
@echo 192.168.4.203 Vip-ibmrac1 >>c:\windows\system32\drivers\etc\hosts
@echo 192.168.4.204 vip-ibmrac2>>c:\windows\system32\drivers\etc\hosts
@echo 172.16.1.53 ssosvr>>c:\windows\system32\drivers\etc\hosts
Copy Code code as follows:
@echo off
Set sthosts=172.16.1.53 Ssosvr
for/f "eol=# Tokens=1 delims="%%i in (%systemroot%\system32\drivers\etc\hosts) do if "%sthosts%" = "%%i" exit
Echo%sthosts%>>%systemroot%\system32\drivers\etc\hosts
Because the test needs to modify the native host frequently, you can modify it by scripting:
Do two batch processing, one intranet, one extranet, switch operation when using
such as intranet. bat
Copy Code code as follows:
CD/D%windir%\system32\drivers\etc
Del Hosts.bak//delete original backup file
ren hosts Hosts.bak//Backup now Host
for/f "eol=# tokens=1,2"%%i in (Hosts.bak) do Call:checkvalue%%i
Goto END
: CheckValue
Echo%2 | find/i "szshequ.com"/seek to make record deletion
If%errorlevel%==1 (echo%1%2 >>hosts)
: End
Type C:\WINDOWS\system32\drivers\etc\hosts
Type C:\WINDOWS\system32\drivers\etc\hosts | Find "szshequ.com" && goto Yes
:: Echo 192.168.2.188 szshequ.com >> ""
echo 192.168.2.188 szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 www.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 bbs.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 cost.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 pp.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 yh.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 club.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 shop.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 images.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 files.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts
echo 192.168.2.188 ajax.szshequ.com >> C:\WINDOWS\system32\drivers\etc\hosts