@echo off

systeminfo

if "%OS 名称%"=="%7%" goto windows7
:windows7
echo 正在设置本机主DNS ,请稍等……
netsh interface ip set dns name="本地连接" source=static addr=8.8.8.8 register=PRIMARY
echo 正在设置本机备用DNS ,请稍等……
netsh interface ip add dns name="本地连接" addr=114.114.114.114 index=2


if "%OS 名称%"=="%10%" goto windows10

:windows10
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------

echo 正在设置本机主DNS ,请稍等……
netsh interface ip set dns name="以太网" source=static addr=8.8.8.8 register=PRIMARY
echo 正在设置本机备用DNS ,请稍等……
netsh interface ip add dns name="以太网" addr=114.114.114.114 index=2
echo 设置完成!
exit

相关文章:

  • 2021-11-23
  • 2021-09-18
  • 2021-12-10
  • 2021-12-10
  • 2022-02-21
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-25
  • 2022-02-10
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
相关资源
相似解决方案