美文网首页
2019-10-30 win10 打开关闭网口脚本

2019-10-30 win10 打开关闭网口脚本

作者: 霍尔元件 | 来源:发表于2019-10-30 14:23 被阅读0次

    来源:https://blog.csdn.net/linfen1520/article/details/88297730

    @echo off
    REM 声明采用UTF-8编码
    chcp 65001
    echo test
    echo 中文测试
    
     
    :: 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
    

    自己改成了两个脚本,分别实现启用网口和禁用网口的功能

    启用脚本

    
    @echo off
    REM 声明采用UTF-8编码
    chcp 65001
    echo test
    echo 中文测试
    
     
    :: 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 启用本地连接b
    netsh interface set interface name="以太网" admin=ENABLED
    
    

    禁用网口

    
    @echo off
    REM 声明采用UTF-8编码
    chcp 65001
    echo test
    echo 中文测试
    
     
    :: 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 禁用本地连接a
    netsh interface set interface name="以太网" admin=DISABLED
    
    

    相关文章

      网友评论

          本文标题:2019-10-30 win10 打开关闭网口脚本

          本文链接:https://www.haomeiwen.com/subject/wdmovctx.html