通过批处理控制网卡接口

Apr 13, 2021

1 min read

将内网网卡名改为"lan",将外网网卡名改为"wlan"

REM copyright unixetc.com

@echo off
set /p input=a:内网/b:外网/c:禁用/d:开启

if "%input%"=="a" goto MA
if "%input%"=="b" goto MB
if "%input%"=="c" goto MC
if "%input%"=="d" goto MD
if not "%input%"== "a" (if not "%input%"=="b"(if not "%input%"=="c" (if not "%input%"=="d" goto ME)))

:MA
echo 单开内网
netsh interface set interface "lan" enabled
netsh interface set interface "wlan" disabled
ping 133.64.8.1 -n 10
echo 设置完成!
pause>nul
exit

:MB
echo 单开外网
netsh interface set interface "lan" disabled
netsh interface set interface "wlan" enabled
ping baidu.com -n 10
echo 设置完成!
pause>nul
exit

:MC
echo 禁用网络
netsh interface set interface "lan" disabled
netsh interface set interface "wlan" disabled
echo 设置完成!
pause>nul
exit

:MD 
echo 开启网络
netsh interface set interface "lan" enabled
netsh interface set interface "wlan" enabled
echo 设置完成!
pause>nul
exit

:ME
echo 啥都没干,退下!
pause>nul
exit