@echo off
echo Checking connection, please wait...
PING -n 1 -w 10 www.google.com|find "Reply from " >nul
if not errorlevel 1 goto :disconnect
if errorlevel 1 goto :connect
:connect
echo Connecting to Internet
rasdial CONNECTION_NAME USERNAME PASSWORD
PING -n 1 www.google.com|find "Reply from " >nul
if not errorlevel 1 goto :chrome
if errorlevel 1 goto :no_connection
:disconnect
echo Disconnecting from Internet
rasdial /disconnect
goto end
:chrome
tasklist /FI "IMAGENAME eq chrome.exe" 2>NUL | find /I /N "chrome.exe">NUL
if ERRORLEVEL 1 (goto:run) ELSE (goto:end)
:run
cd\Users\Soumya\AppData\Local\Google\Chrome\Application\
chrome.exe
:no_connection
echo Connection is not avaialble at the moment
echo Try again later
pause
:END
i wrote the above the above batch program to connect/disconnect frm the internet
its working fine but the first ping takes unnecessary time
all i need to do is check if 'CONNECTION_NAME' is active or not
I don't remember anything about RAS, it's been a while. But the intial ping when not connect takes a long time because you have to wait for a DNS timeout. You can avoid that by pinging an IP address instead.