Command for finding internet connect before connection?

  • Thread starter Thread starter John
  • Start date Start date
J

John

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
 
John said:
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=p....cmdprompt.admin&hl=en&lr=&ie=UTF-8&scoring=d




A VBScript version of the above:

http://groups.google.com/[email protected]
 
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




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


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