Win10 一键启用&禁用以太网bat命令

转自:https://blog.csdn.net/linfen1520/article/details/88297730

 

 

@echo off 
 
:: 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" 
:-------------------------------------- 
 
cls
@ECHO OFF
title 启用或禁用本地连接
CLS
color 0a
GOTO MENU
:MENU
ECHO.
ECHO. ==============启用禁用本地连接==============
ECHO.
ECHO. 1 禁用本地连接a
ECHO. 2 启用本地连接b
ECHO. 3 退 出
ECHO. ==========================================
ECHO.
ECHO.
echo. 请输入选择项目的序号:
set /p ID=
if "%id%"=="1" goto qiyong
if "%id%"=="2" goto jinyong
if "%id%"=="3" exit
PAUSE
:qiyong
echo 禁用本地连接a
netsh interface set interface name="以太网" admin=DISABLED
goto MENU
:jinyong
echo 启用本地连接b
netsh interface set interface name="以太网" admin=ENABLED
GOTO MENU

 

上一篇:Windows10为什么老是显示系统许可证已过期


下一篇:vbs调用批处理、PowerShell传参,加域等