根据条件绑定hosts

@echo off
 CLS
 ECHO.
 :init
 setlocal DisableDelayedExpansion
 set "batchPath=%~0"
 for %%k in (%0) do set batchName=%%~nk
 set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
 setlocal EnableDelayedExpansion
 :checkPrivileges
 NET FILE 1>NUL 2>NUL
 if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
 :getPrivileges
 if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
 ECHO.
 ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
 ECHO args = "ELEV " >> "%vbsGetPrivileges%"
 ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
 ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
 ECHO Next >> "%vbsGetPrivileges%"
 ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
 "%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
 exit /B
 :gotPrivileges
 setlocal & pushd .
 cd /d %~dp0
 if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)

color 1A
 :firstinput
 echo  echo 请输入需要修复的平台名称的拼音       * echo 
 echo 例如平台名称为"百度",则输入"baidu"  *
 echo **
 set /p product=请输入拼音,并按确定键:
 if "%product%"=="longba" ( goto longbachange ) else ( if "%product%"=="qianying" ( goto qianyingchange ) else ( goto errorinput ))

:longbachange
 set /p domain=请输入要修复的"%product%"的域名,并按确定键:
 find /i "%domain%" C:\Windows\System32\drivers\etc\hosts>nul
 if "%errorlevel%"=="0" goto longbaview
 if "%errorlevel%"=="1" goto longbarepair2

:longbaview
 echo  echo 您已修复过此域名,是否重新修复       * echo ***
 echo 重新修复请输入“y”,退出请输入"n"或直接关闭程序 *
 echo ***
 set /p value=请输入:
 if "%value%"=="y" goto longbarepair1
 if "%value%"=="n" goto allexit

:longbarepair1
 pushd "C:\Windows\System32\drivers\etc"
 copy hosts hosts.bak>nul
 find /v "%domain%" hosts.new
 move hosts.new hosts>nul
 echo,>>hosts
 echo 119.42.34.47  %domain%>>%Windir%\system32\drivers\etc\hosts
 echo 
 echo 修复已完成,祝您游戏愉快!       *
 echo 
 echo 请按任意键退出!                 *
 echo 
 pause
 exit

:longbarepair2
 pushd "C:\Windows\System32\drivers\etc"
 copy hosts hosts.bak>nul
 echo,>>hosts
 echo 119.42.34.47  %domain%>>%Windir%\system32\drivers\etc\hosts
 echo 
 echo 修复已完成,祝您游戏愉快!       *
 echo 
 echo 请按任意键退出!                 *
 echo 
 pause
 exit

:qianyingchange
 set /p domain=请输入要修复的"%product%"的域名,并按确定键:
 find /i "%domain%" C:\Windows\System32\drivers\etc\hosts>nul
 if "%errorlevel%"=="0" goto qianyingview
 if "%errorlevel%"=="1" goto qianyingrepair2

:qianyingview
 echo  echo 您已修复过此域名,是否重新修复       * echo ***
 echo 重新修复请输入“y”,退出请输入"n"或直接关闭程序 *
 echo ***
 set /p value=请输入:
 if "%value%"=="y" goto qianyingrepair1
 if "%value%"=="n" goto allexit

:qianyingrepair1
 pushd "C:\Windows\System32\drivers\etc"
 copy hosts hosts.bak>nul
 find /v "%domain%" hosts.new
 move hosts.new hosts>nul
 echo,>>hosts
 echo 119.42.34.47  %domain%>>%Windir%\system32\drivers\etc\hosts
 echo 
 echo 修复已完成,祝您游戏愉快!       *
 echo 
 echo 请按任意键退出!                 *
 echo 
 pause
 exit

:qianyingrepair2
 pushd "C:\Windows\System32\drivers\etc"
 copy hosts hosts.bak>nul
 echo,>>hosts
 echo 119.42.34.47  %domain%>>%Windir%\system32\drivers\etc\hosts
 echo 
 echo 修复已完成,祝您游戏愉快!       *
 echo 
 echo 请按任意键退出!                 *
 echo 
 pause
 exit

:allexit
 echo 
 echo 您已终止修复程序,按任意键退出! *
 echo 
 pause
 exit

:errorinput
 echo *
 echo 您输入的平台名称有误!                  *
 echo *
 echo 请联系平台客服人员确认正确名称          *
 echo 
 echo 按确定键重新输入,退出请输入"n"或直接关闭程序    *
 echo 
 set /p what=请输入:
 if "%what%"=="n" goto allexit
 pause
 goto firstinput

发表评论