首页 > 代码库 > 命令行加host文件
命令行加host文件
如何命令行加host文件?
1.首先要去掉hosts文件的系统属性和只读属性,然后就可以了。所以命令应为:
@echo off
attrib "%windir%\System32\Drivers\etc\hosts" -s -h -r
echo 127.0.0.1 www.baidu.com >> %windir%\system32\drivers\etc\hosts
attrib "%windir%\System32\Drivers\etc\hosts" -s -h -r
pause
这是正常程序,下面是我以前写过的,给予参考
@ECHO OFF
color f1
mode con cols=60 lines=20
echo.
echo 国内知名视频网站片头广告屏蔽工具
echo 程序设计:YiDong
echo.
echo 屏蔽的网站有:
echo.
echo 优酷\土豆\迅雷看看\56\搜狐\新浪\酷6
echo.
echo PPTV\cntv\乐视\奇艺\6间房\激动网
echo ======================
echo 确认要屏蔽,请按回车键
echo ======================
echo -----------------------------------------------------
echo 如果屏蔽给你带来了不便,请进入
echo.
echo 系统盘\windows\system32\drivers\etc
echo.
echo 用记事本打开hosts文件,删除已屏蔽的站点
echo ------------------------------------------------------
pause >>nul
attrib "%windir%\System32\Drivers\etc\hosts" -s -h -r
>>"%windir%\System32\Drivers\etc\hosts" ECHO #优酷屏蔽广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 static.lstat.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 static.atm.youku.com/crossdomain.xml
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valb.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valc.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valf.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valo.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valp.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 vid.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 walp.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #土豆屏蔽广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 adextensioncontrol.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 adplay.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 adcontrol.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 iwstat.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 nstat.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stats.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 at-img1.tdimg.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #127.0.0.1 at-img2.tdimg.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #127.0.0.1 at-img3.tdimg.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 *.p2v.tudou.com*
>>"%windir%\System32\Drivers\etc\hosts" ECHO.
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去迅雷看看广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pubstat.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 mcfg.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 biz5.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 float.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 recommend.xunlei.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 cl.kankan.xunlei.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去56广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 acs.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 acs.agent.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 acs.agent.v-56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 bill.agent.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 union.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 v16.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去搜狐高清广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 images.sohu.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去新浪视频广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 dcads.sina.com.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去酷6广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 1.allyes.com.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 analytics.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat0.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat1.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat2.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat3.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 ku6afp.allyes.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去pptv.com广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pp2.pptv.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 去cntv广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 d.cntv.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去乐视广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pro.letv.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去奇艺广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 afp.qiyi.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 focusbaiduafp.allyes.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去6间房广告(还有一点点残留)
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 simba.6.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pole.6rooms.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 shrek.6.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 union.6.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去激动网广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 86file.megajoy.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 86get.joy.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 86log.joy.cn
attrib "%windir%\System32\Drivers\etc\hosts" +s +h
color f3
mode con cols=60 lines=8
echo ======================================================
echo.
echo 屏蔽完成,按回车退出
echo.
echo ======================================================
pause >>nul
@echo off
attrib "%windir%\System32\Drivers\etc\hosts" -s -h -r
echo 127.0.0.1 www.baidu.com >> %windir%\system32\drivers\etc\hosts
attrib "%windir%\System32\Drivers\etc\hosts" -s -h -r
pause
@ECHO OFF
color f1
mode con cols=60 lines=20
echo.
echo 国内知名视频网站片头广告屏蔽工具
echo 程序设计:YiDong
echo.
echo 屏蔽的网站有:
echo.
echo 优酷\土豆\迅雷看看\56\搜狐\新浪\酷6
echo.
echo PPTV\cntv\乐视\奇艺\6间房\激动网
echo ======================
echo 确认要屏蔽,请按回车键
echo ======================
echo -----------------------------------------------------
echo 如果屏蔽给你带来了不便,请进入
echo.
echo 系统盘\windows\system32\drivers\etc
echo.
echo 用记事本打开hosts文件,删除已屏蔽的站点
echo ------------------------------------------------------
pause >>nul
attrib "%windir%\System32\Drivers\etc\hosts" -s -h -r
>>"%windir%\System32\Drivers\etc\hosts" ECHO #优酷屏蔽广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 static.lstat.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 static.atm.youku.com/crossdomain.xml
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valb.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valc.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valf.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valo.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 valp.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 vid.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 walp.atm.youku.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #土豆屏蔽广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 adextensioncontrol.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 adplay.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 adcontrol.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 iwstat.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 nstat.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stats.tudou.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 at-img1.tdimg.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #127.0.0.1 at-img2.tdimg.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #127.0.0.1 at-img3.tdimg.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 *.p2v.tudou.com*
>>"%windir%\System32\Drivers\etc\hosts" ECHO.
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去迅雷看看广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pubstat.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 mcfg.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 biz5.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 float.sandai.net
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 recommend.xunlei.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 cl.kankan.xunlei.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去56广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 acs.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 acs.agent.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 acs.agent.v-56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 bill.agent.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 union.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 v16.56.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去搜狐高清广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 images.sohu.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去新浪视频广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 dcads.sina.com.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去酷6广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 1.allyes.com.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 analytics.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat0.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat1.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat2.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 stat3.888.ku6.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 ku6afp.allyes.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去pptv.com广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pp2.pptv.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 去cntv广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 d.cntv.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去乐视广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pro.letv.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去奇艺广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 afp.qiyi.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 focusbaiduafp.allyes.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去6间房广告(还有一点点残留)
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 simba.6.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 pole.6rooms.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 shrek.6.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 union.6.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO #去激动网广告
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 86file.megajoy.com
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 86get.joy.cn
>>"%windir%\System32\Drivers\etc\hosts" ECHO 127.0.0.1 86log.joy.cn
attrib "%windir%\System32\Drivers\etc\hosts" +s +h
color f3
mode con cols=60 lines=8
echo ======================================================
echo.
echo 屏蔽完成,按回车退出
echo.
echo ======================================================
pause >>nul
命令行加host文件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。