输入域名自动绑定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
 set /p domain=请输入您要修复的域名,并按确定键:

:change
 find /i "%domain%" C:\Windows\System32\drivers\etc\hosts>nul
 if "%errorlevel%"=="0" goto view
 if "%errorlevel%"=="1" goto repair2

:view
 echo 您已修复过此域名,是否重新修复
 echo 重新修复请输入“y”,否则请直接关闭程序
 set /p value=请输入:
 if "%value%"=="y" goto repair1
 if "%value%"=="Y" goto repair1

:repair1
 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 修复已完成,祝您游戏愉快!
 pause
 exit

:repair2
 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 修复已完成,祝您游戏愉快!
 pause
 exit

发表评论