金狮镖局 Design By www.egabc.com
@echo 127.0.0.1 baidu.com C:\Windows\System32\Drivers\etc\hosts
这样就是换一行写入。
如果还想换一行,就写:
复制代码 代码如下:
@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-ibmrac2C:\Windows\System32\Drivers\etc\hosts
@echo 172.16.1.53 ssosvrC:\Windows\System32\Drivers\etc\hosts


复制代码 代码如下:
@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



由于测试需要经常修改本机host,可以用脚本修改:
分别做两个批处理,一个内网,一个外网,用的时候切换运行即可
如内网.bat
复制代码 代码如下:
cd /d %windir%\system32\drivers\etc
del hosts.bak //删除原来备份文件
ren hosts hosts.bak //备份现在host
for /f "eol=# tokens=1,2" %%i in (hosts.bak) do call :checkvalue %%i %%j
goto end
:checkvalue
echo %2 | find /i "szshequ.com" //寻找制定记录删除
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
标签:
批处理,host

金狮镖局 Design By www.egabc.com
金狮镖局 免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
金狮镖局 Design By www.egabc.com

评论“用批处理修改host文件的代码”

暂无用批处理修改host文件的代码的评论...

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。