Before using the batch file, rename the internal network adapter to lan and the external network adapter to wlan. The script then lets you choose whether to enable only the internal network, enable only the external network, disable both adapters, or turn both adapters back on.
The selection menu is controlled by a single input value:
a: enable the internal network onlyb: enable the external network onlyc: disable network accessd: enable both network adapters
The actual enabling and disabling is handled through netsh interface set interface, so the batch file should be run with the permissions required to change network adapter settings.
REM copyright 0x8.net
@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
When a is entered, the script enables lan, disables wlan, and pings 133.64.8.1 ten times. When b is entered, it does the reverse and pings baidu.com ten times. Options c and d simply disable or enable both interfaces without running a ping check. Any other input falls through to the final branch and exits without changing the network state.