我有个批处理,根据当前IP地址判断是否需要打开代理,供参考。
@echo off
@rem home: 192.168.1.9 jx: 172.16.33.
@rem sleep 3 seconds
ping 1.1.1.1 -n 1 -w 3000 > nul
for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "v4 ???·"') do set ip=%%i
SET ip=%ip:~1%
echo ip %ip%
@rem change 6 below to longer if want specifc match
set id=%ip:~0,6%
echo id %id%
@rem if 1., means home
echo.
if "%id%"=="172.16" (
set ProxyValue=1
echo #####.....#####.....#####..... Adding proxy 设置代理中
) else (
set ProxyValue=0
echo #####.....#####.....#####..... Proxy not needed 无需设置代理
)
echo.
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoDetect /t REG_DWORD /d %ProxyValue% /f > nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d %ProxyValue% /f > nul
ipconfig /flushdns > nul
@rem pause
【 在 Thulium 的大作中提到: 】
: 自动设置代理:有线局域网时使用代理,无线网时禁用代理。
: 谢谢~
:
--
FROM 219.143.248.*