Connection test batchfile (cleanup & test)

December 22, 2010 at 05:20:46
Specs: XP/Vista/7, P4 3Ghz 1G ram
I've created this batch file for the local dsl guys and customers to test their connection. I've put it together from a mix of sources. Would someone please help me clean it up?
I've tested it pretty well, and believe it won't fail 1 test.
Here is how the test works;
test Network card - works or Bad network card /driver missing
find gateway address - connects to router/dsl or cable missing or restart router
test internet - Internet works or dls/router works, but internet is NOT working
test browser - Get user input (y it works) or your browser has been hijacked.

@echo off

:Welcome
echo Welcome to the Computer Doctor Connection test
echo 208 E. Laurel Street Scottsboro Alabama
echo www.puterdr.com
pause
cls

:start
::# Set varible for gateway
@echo please wait...

::# Define a temp variable 'DefaultGateway'
@For /f "tokens=3" %%* in (
'route.exe print ^|findstr "\<0.0.0.0\>"'
) Do @Set "DefaultGateway=%%*"

:netcard
SET CONNECT=
Color 0c
echo -
echo -
echo -
echo *****Testing your network card****
pause
Color 0f
ping 127.0.0.1
::if errorlevel 1 set connect=NOT
Color 0c
cls
echo -------------------------------------
IF ERRORLEVEL 1 GOTO NEEDNET
echo Your netowrk card is working.
::echo ****You network card is%CONNECT% working****
Pause


:gateway
cls
set connect=
echo -
echo -
echo -
echo ****Testing your router****
pause
Color 0f
ping %DefaultGateway%
IF ERRORLEVEL 1 GOTO routerfail
IF ERRORLEVEL 0 GOTO routerpass


:IF NOT ERRORLEVEL 1 GOTO PASS

:routerpass
Color 0c
cls
echo -------------------------------------

echo ****Your router/wirelss or cable/DSL modem is wroking****
pause
GOTO internet

:routerfail
Color 0c
cls
echo -------------------------------------
echo ****Please unplug and replug your router,-
echo ****cable/DSL modem for 1 minutes then replug and wait 1 minute.
echo ****Re-Plug your network cables.
echo ****Check the light on your router, relative to your ethernet cable
echo ****Try unpluging the cable to this computer and see if the light goes out.
pause

:restart
cls
echo -------------------------------------
echo After restarting your Router cable/DSL modem, do you want to restart this test?
set /p reply=y or n
if "%reply%" == "y" goto start
pause


:internet
cls
set connect=
echo -
echo -
echo -
echo ****Testing your internet connection****
pause
Color 0f
ping www.yahoo.com
if errorlevel 1 set goto netpass
if errorlevel 1 set goto netfail

:netpass
Color 0c
cls
echo --------------------------------------
echo ****Your internet connection is working

:browser
cls
echo Testing Browser
start http:\\www.puterdr.com\test

textbox.Focus()
echo Does your internet broswer Work?
set /p reply=y or n
if "%reply%" == "n" goto hijacked


:sucess
cls
echo The test has completed sucessfully!
pause
GOTO EOF

:neednet
cls
echo --------------------------------------
echo ****Your network card is bad!!
echo ****Please contact the Computer Doctor at 256-259-2225
pause
goto EOF

:netfail
cls
echo --------------------------------------
echo ****Your router is working, but you have no internet!
echo ****Try restarting your router, and wait 1 minutes
pause
cls
echo --------------------------------------
echo ****Check that your cable/DLS modem's internet/DSL light is on.
echo ****Please contact Your internet provider.
pause
cls
echo --------------------------------------
echo ****There is nothing further to test!
pause
goto EOF


:hijacked
cls
echo --------------------------------------
echo ****Your broswer has been hijacked!!
echo ****Please contact the Computer Doctor at 256-259-2225
pause

The Computer Dr
Chris Robertson


See More: Connection test batchfile (cleanup & test)

Report •


#1
January 1, 2011 at 04:44:48
You have so many uncorrect command usage's in your script, cant tell them all.

But:

"::# Define a temp variable 'DefaultGateway'
@For /f "tokens=3" %%* in (
'route.exe print ^|findstr "\<0.0.0.0\>"'
) Do @Set "DefaultGateway=%%*""

Why dont use:

for /f "tokens=11" %%j in ('ipconfig') do set DEFAULT-GATEWAY=%%j
for /f "tokens=13" %%j in ('ipconfig') do set SUBNETMASK=%%j
for /f "tokens=15" %%j in ('ipconfig') do set IP-ADDRESS=%%j

if %IP%==0.0.0.0 ipconfig /renew
if not "%IP%" equ " a" goto EXIT

Happy is ONE who says I am an OttoMAN.


Report •
Related Solutions


Ask Question