2022年3月30日星期三

Windows系统host文件快速替换

 以下文本另存为.BAT文件


@echo off

::取消host的只读属性

attrib -r -a -s -h %windir%\system32\drivers\etc\hosts 

::复制host文件

copy  %~sdp0\hosts     C:\Windows\System32\drivers\etc\hosts 

::设置host的只读属性

attrib +r +a +s +h %windir%\system32\drivers\etc\hosts

::刷新

ipconfig /flushdns

::刷新

ping -n 2 127.0.0.1 >nul


需要设置的host(如下示例)另存为hosts文件并与.BAT文件在同一文件夹,右键以管理员执行


104.111.167.111 contentstorage.osi.office.net

13.107.42.13 onedrive.live.com

20.190.144.166 login.live.com

40.79.207.82 skyapi.onedrive.live.com

13.107.42.12 d.docs.live.net

52.109.48.6 contentsync.onenote.com

52.109.48.27 hierarchyapi.onenote.com

52.109.124.47 ocws.officeapps.live.com

52.109.48.0 www.onenote.com

13.107.42.16 config.edge.skype.com

52.109.124.51 roaming.officeapps.live.com

52.109.48.4 pagecontentsync.onenote.com

104.111.167.110 api.onedrive.live.com

23.57.112.223 c1-onenote-15.cdn.office.net

13.107.42.12 docs.live.net

104.44.88.28 storage.live.com

20.197.71.89 skydrive.wns.windows.com

20.198.162.78 client.wns.windows.com

52.168.112.67 mobile.pipe.aria.microsoft.com

23.57.114.164 oneclient.sfx.ms

40.79.207.82 skydrivesync.policies.live.net

13.107.42.12 api.onedrive.com

13.107.42.12 public.bn.files.1drv.com

13.107.42.12 public.dm.files.1drv.com

104.111.162.163 cdn.onenote.net

157.240.199.14 ad.atdmt.com

117.18.232.200 officeimg.vo.msecnd.net

13.107.6.171 onenote.officeapps.live.com