:: Author: gx :: Date: 2025-3-19 :: Description: :: - 启用双NIC的情况下, 通过提高WIFI接口优先级和添加网段路由, 实现访问内网资源走有线连接, 访问外网走WIFI。 @echo off :: 提权 %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0" setlocal enabledelayedexpansion echo Please select the operating mode echo [1] "Changing route and interface metrics" echo [2] "Restore Defaults" choice /c 12 /n cls if %errorlevel%==1 ( echo CHANGE :: 更改接口度量值 echo Changing interface metric... netsh interface ipv4 set interface "WLAN" metric=10 :: 打印网关信息 echo. echo -------------------- echo WIFI Gateway List echo HNHK: 192.168.10.1 echo CAMPUS: 192.168.6.1 echo -------------------- echo. :: 添加永久路由 echo Adding permanent routes... route -p add 10.0.0.0 mask 255.0.0.0 10.34.28.1 metric 1 ) else if %errorlevel%==2 ( echo FALLBACK echo Restore the interface metric to automatic... netsh interface ipv4 set interface "WLAN" metric=automatic route delete 10.0.0.0 -p ) echo. powershell -Command "& {Write-Host 'All down, Need to restart the computer.' -ForegroundColor Black -BackgroundColor Green}" timeout /t 8 exit