Saturday, December 29, 2012

autoDial script for Windows

This is my personal script or batchfile because my connection is not that reliable or should I say the connection sometimes stops working. So I created this script from various sites to complete it.
Sorry I got lazy what sites are the sources but I just searched how to dial using command prompt.

This script runs in msdos shell and uses rasdial to control the dial up and there is an existing dial up account named Sun before creating this script. See the script I made below...

@echo off
:goagain

ping www.google.com | find "TTL"

if ERRORLEVEL 1 goto reconnect
if ERRORLEVEL 0 goto lineok

:reconnect
echo Disconnected
rasdial Sun /disconnect
rasdial Sun

:lineok
echo line ok
echo Waiting for 50 seconds before checking connection again...
PING 1.1.1.1 -n 50 -w 1000 >NUL
goto goagain


This script filename is autodial.bat

As the script goes the @echo off line hides the commands,
the  ping www.google.com | find "TTL" is to check if the connection gets a ping reply,

the rasdial [connection name] connects the internet
and adding /disconnect disconnects the internet.

the PING 1.1.1.1 -n 50 -w 1000 >NUL is the delay command where it will wait for 50 seconds before going to the next line.


Also this script goes on an endless loop so to stop the script just either close the command prompt window or press ctrl + c to cancel the script.


Hope this small script may help others in any way. Happy Holidays!!!