@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)
::判断本地连接 赋值a
for /f "tokens=2,3" %%i in ('ipconfig /all^|findstr /r "以太网适配器"') do echo %%i %%j >net-name.txt
for /f "tokens=1 delims==:" %%d in (net-name.txt) do set a=%%d
::判断当前DNS 赋值c
for /f "tokens=15" %%i in ('ipconfig /all^|findstr /r "DNS"') do echo %%i >DNS.txt
for /f "tokens=1 delims==." %%h in (DNS.txt) do set c=%%h
::比较当前DNS
if "%c%"=="8" (goto ToAliDNS) else ( if "%c%"=="223" ( goto ToGoogleDNS ))
::请根据实际情况更改以下内容
:ToGoogleDNS
echo Google DNS
color 1A
echo ***
echo 正在修复,请稍后…….
echo ***
netsh interface ip set dns name="%a%" source=static addr=8.8.4.4
netsh interface ip add dns "%a%" 8.8.8.8
goto EXIT
:ToAliDNS
echo ALI DNS
color 1A
echo ***
echo 正在修复,请稍后…….
echo ***
netsh interface ip set dns name="%a%" source=static addr=223.5.5.5
netsh interface ip add dns "%a%" 223.6.6.6
goto EXIT
:EXIT
ipconfig /flushdns
echo *
ipconfig /flushdns
echo *
ipconfig /flushdns
del net-name.txt
del DNS.txt
echo *
echo 修复已完成,祝您游戏愉快
echo *
echo 请按任意键退出
echo **
pause
exit