1.获取管理员权限
2.获取当前网络SSID
3.模糊匹配进入ifelse
4.不同网络下设置你需要的IP和DNS
开机任务计划自行度娘不详述
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
@echo off
set ssid=None
@for /f "tokens=1,2,3" %%i in ('netsh WLAN show interfaces') do (
if [%%i]==[SSID] set ssid=%%k
)
echo WIFI---%ssid%
echo %ssid%|findstr "模糊匹配名称" >nul
if %errorlevel% equ 0 (
echo This is who's wifi.
netsh interface ip set address name="WLAN" source=static addr=192.168.4.110 mask=255.255.255.0 gateway=192.168.4.1
netsh interface ip set dns name="WLAN" source=static addr=114.114.114.114
) else (
echo This is not who's wifi.
netsh interface ip set address name="WLAN" source=dhcp
netsh interface ip set dns name="WLAN" source=dhcp
)
TIMEOUT /T 3