本批处理是解决Steam登陆慢的问题专门编写。原理是修改hosts文件让相关域名指向离大陆最近的位于中国香港的服务器IP地址。
灵感来自天下网吧小程序用户的分享:
大家知道修改Hosts文件可以让指定的域名直接用指定的ip来访问,而Steam大陆登陆慢就是跟域名指向的IP太远导致访问慢,甚至不能访问。本批处理的作用就是帮网吧自动设置hosts到指定的中国香港IP或者本机IP——127.0.0.1,下面源码复制保存到本机,文件命名为txwb.bat,然后开超级运行,根据提示操作,下面是源码:
@echo off @echo ###################################################### echo 说明: echo 天下网吧:人人为我我为人人 echo 一招解决最近网吧Steam 登录慢问题 echo 请开超级运行,建议建个还原点以免出现问题时可以恢复 echo 部分网吧系统装有劫持HOSTS的程序会导致运行重启后不生效 echo "请以管理员身份运行此脚本,注意杀毒软件提示,一定要允许" echo "如设置有误,重新运行此脚本进行选择即可" echo "如果有任何问题,可以访问天下网吧小程序一起讨论交流" echo "本文根据以下帖子原理编写的代码:一招解决最近网吧steam 登录慢问题 echo _网吧技术_天下网吧论坛 - Powered by Discuz!https://bbs.txwb.com/ echo thread-2084938-1.html" echo "如果需要开机运行精简版请使用天下网吧小程序发帖提出你的需求!" @echo ###################################################### rem echo api.steampowered.com cd %systemroot%\system32\drivers\etc rem 删除原来备份文件 if exist hosts.bak del hosts.bak rem 重命名hosts文件 ren hosts hosts.bak rem 新建hosts文件 echo 1 0>hosts 1>nul 2>nul :Menu echo 1.使用中国香港移动IP echo 2.使用中国香港2 echo 3.中国香港3 echo 4.还原Hosts文件为初始状态 echo 5.直接使用127.0.0.1 echo. echo 请根据客户网络环境选择对应的选项: :Input set "network=" set /p network=请输入您的选项编号(1/2/3/4/5),按ENTER确定: rem echo %network% if /i "%network%"=="1" goto :txwb1 if /i "%network%"=="2" goto :txwb2 if /i "%network%"=="3" goto :txwb3 if /i "%network%"=="5" goto :txwb4 if /i "%network%"=="4" goto :RECOVERY echo 输入错误,请重新输入 &pause>nul&goto Input :txwb1 rem 插入中国香港移动的地址映射 echo 223.119.221.248 api.steampowered.com >>hosts ipconfig/flushdns ping api.steampowered.com goto End :txwb2 rem 插入中国香港2映射 echo 104.110.72.183 api.steampowered.com >>hosts ipconfig/flushdns ping api.steampowered.com goto End :txwb3 rem 插入中国香港3映射 echo 104.85.204.121 api.steampowered.com >>hosts ipconfig/flushdns ping api.steampowered.com goto End :txwb3 rem 插入中国香港4映射 echo 127.0.0.1 api.steampowered.com >>hosts ipconfig/flushdns ping api.Steampowered.com goto End :RECOVERY echo # Copyright (c) 1993-2009 Microsoft Corp.>hosts echo #>>hosts echo # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.>>hosts echo #>>hosts echo # This file contains the mappings of IP addresses to host names. Each>>hosts echo # entry should be kept on an individual line. The IP address should>>hosts echo # be placed in the first column followed by the corresponding host name.>>hosts echo # The IP address and the host name should be separated by at least one>>hosts echo # space.>>hosts echo #>>hosts echo # Additionally, comments (such as these) may be inserted on individual>>hosts echo # lines or following the machine name denoted by a '#' symbol.>>hosts echo #>>hosts echo # For example:>>hosts echo #>>hosts echo # 102.54.94.97 rhino.acme.com # source server>>hosts echo # 38.25.63.10 x.acme.com # x client host>>hosts echo.>>hosts echo # localhost name resolution is handled within DNS itself.>>hosts echo # 127.0.0.1 localhost>>hosts echo # ::1 localhost>>hosts echo.>>hosts goto End :End pause exit
运行后效果如下: