自动修改DNS

@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 >DNS.txt
 for /f "tokens=1 delims==:" %%d in (DNS.txt) do set a=%%d
 ::请根据实际情况更改下面三行
 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%" 114.114.115.115
 ipconfig /flushdns
 ipconfig /flushdns
 ipconfig /flushdns
 del DNS.txt
 pushd "C:\Windows\System32\drivers\etc"
 echo.>hosts
 echo *
 echo *修复已完成,祝您游戏愉快 *
 echo *
 echo **
 echo 请按任意键退出
 echo **
 pause
 exit

发表评论