I need to check the vpn connection when is online/up with a batch file.
Actually i use this code:
PING -n 5 www.google.com|FIND /I "TTL">NUL
IF NOT "%ERRORLEVEL%"=="1" (
Echo "Vpn Connection Is Up"
)
IF "%ERRORLEVEL%"=="1" (
Echo "Vpn Connection Is Down"
)
Sometimes the ping give a non response or give a general failure response.
I would like to know that there is a better batch code alternative than the ping command.
I tried this alternative codes but do not recognize vpn when is online/up because the adapter is always in my pc installed.
First Alternative Code:
ipconfig|find /i "VPN" && GOTO startAPP || GOTO connectVPN
Second Alternative Code:
ipconfig|find /i "VPN"
if %errorlevle%==1 goto:connectVPN
echo Starting APP !
exit/b
:connectVPN
echo connecting to VPN
Third Alternative Code:
:start
cls
rasdial | find /I "%vpnname%" > nul
if errorlevel 1 goto vpndown
if errorlevel 0 goto vpnup
Can You recommend an alternative command to ping to be integrated into my batch code please ?
The alternatives code do not recognize when vpn connection is online, it's recognize if exist the adampter installed in my pc but i need to know when vpn is online/up (ready to go on internet).