connecting to/disconnecting form internet

i'm not sure if i am in the right forum
but i wud really appreciate a little help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
@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

is there a better way to achieve this??
Not exactly a Programming question.

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.
actually i was asking for a way to avoid ping as its not native command

i was wondering if it was possible to use the output of the rasdial command
using it as a sort of return value

i mean when the computer is connected to internet it clearly prints " you are already connected to CONNECTION_NAME"
figured it

the ping can be replaced by
1
2
rasdial |find "No connections" >nul
if     errorlevel 1 (goto :disconnect) else (goto :connect)



works perfectly ^_^
Topic archived. No new replies allowed.