删除本地hosts指定字符所在行

 

@echo off

rem -----------------------检查本地DNS解析并删除无效的解析---------------
set filename1="C:\Windows\System32\drivers\etc\hosts"
set filename2="C:\Windows\System32\drivers\etc\hosts-bak"
if exist %filename1% (
  copy %filename1% %filename2%
  del %filename1%
  )

set str1=111
set str2=222
findstr /r /v /e  "! %str1%" %filename2% > %filename1% 
findstr /r /v /e  "! %str2%" %filename2% > %filename1% 

rem ---------------------------------------------------------------------

rem -----------------------检查本地DNS解析并删除无效的解析---------------
ipconfig/flushdns
ping  onebox.boe.com.cn
ping  boebox.boe.com.cn
color 0a
echo.--------------------------------------------
echo. 请确认所ping网站对应IP是否xxxx
echo.---------------------------------------------
rem -----------------------------------------------

pause

 

posted @ 2023-05-17 17:44  你好!2022  阅读(118)  评论(0编辑  收藏  举报