Windows Tips - Connect to VPN via command line

@echo off
 
ipconfig | findstr IPv4 | findstr 172.16 > NUL
 
if not "%ERRORLEVEL%"=="0" (
    echo [%DATE%_%TIME%] Try connecting to VPN.
    rasdial "VPN NETWORK NAME" "Username" *
) else (
    echo [%DATE%_%TIME%] Already connected.
)