Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Command for finding internet connect before connection?

1 view
Skip to first unread message

John

unread,
Nov 21, 2003, 9:26:49 PM11/21/03
to
I am using the RASDIAL command in a batch file for users to connect to our
VPN, so it can also map the network drive. This works great, but I would
like to see if it can check for a valid connection to the internet (IP
address or other method) before executing the command, as I would like for
this batch file to be added to startup. All of these users travel, and
often work offline. Any suggestions or recommendations would be
appreciated.

Here is the current batch:

@echo off
rasdial "OurCompany VPN" /domain:domain_name
if errorlevel 1 goto finish_error
net use P: \\10.0.0.1\share_name /persistent:no
if errorlevel 1 goto finish_nomap
goto finish_noerror

:finish_error
echo There was an error completing your connection.
pause
goto exit_batch

:finish_nomap
echo You have connected to the VPN, but the connection to the mapped drive
could not be completed.
pause
goto exit_batch

:finish_noerror
echo You have been successfully connected.
pause

:exit_batch


Torgeir Bakken (MVP)

unread,
Nov 22, 2003, 12:00:18 AM11/22/03
to
John wrote:

> I am using the RASDIAL command in a batch file for users to connect to our
> VPN, so it can also map the network drive. This works great, but I would
> like to see if it can check for a valid connection to the internet (IP
> address or other method) before executing the command, as I would like for
> this batch file to be added to startup. All of these users travel, and
> often work offline. Any suggestions or recommendations would be
> appreciated.

Hi

Ping an IP address and test for the text TTL.

Command line solutions:

ping.exe -n 1 IPAddressHere | find "TTL="

http://groups.google.com/groups?q=ping+ttl+group:microsoft.public.win2000.cmdprompt.admin&hl=en&lr=&ie=UTF-8&scoring=d


A VBScript version of the above:

http://groups.google.com/groups?selm=3EB2AA54.EBB5ECBC%40hydro.com


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Jerold Schulman

unread,
Nov 23, 2003, 6:29:32 AM11/23/03
to

I would use RasPhone instead of RasDial as it has auto retry capability on
failure.

See tip 228 and links in the 'Tips & Tricks' at http://www.jsiinc.com

set connected=N
for /f "Tokens=*" %%c in ('ping -n 1 IPAddress ^| FIND "TTL"') do (
set connected=Y
)
If "%connected%" EQU "Y" goto connected


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com

0 new messages