I wrote this today to provide an easy way for anyone to see if a computer is on the network/internet and even do some basic troubleshooting.
It assumes that you are on a LAN, with a router at 192.168.1.1 If someone wanted to take the time they could probably extract the info from an ipconfig to make it more portable, but like it is, it will work for a lot of folks. Just cut and past into a text file and save with a .bat extension and you should be good to go. Could easily be put on a floppy or e-mailed to someone to test with.
Here is the basic rundown on what it does[list=1][*]Trys to ping
www.google.com with 1 packet, if it succeeds it ends with a success message.[*]If it fails, it will try 3 more packets, if that succeeds, it will finish but warn it detected packet loss.[*]If it still fails, it will try by IP address to test DNS, if this succeeds it will tell you that it had DNS issues.[*]If it still fails it will try to ping 192.168.1.1 and if it succeeds will tell you it can reach the router but not internet.[*]If the ping to 192.168.1.1 fails, it will tell you the network is down.[/list=1]
Code:
@echo off
ECHO Checking connection, please wait...
PING -n 1 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS
IF ERRORLEVEL 1 goto :TRYAGAIN
:TRYAGAIN
ECHO FAILURE!
ECHO Let me try a bit more, please wait...
@echo off
PING -n 3 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS2
IF ERRORLEVEL 1 goto :TRYIP
:TRYIP
ECHO FAILURE!
ECHO Checking DNS...
ECHO Lets try by IP address...
@echo off
ping -n 1 216.239.37.99|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESSDNS
IF ERRORLEVEL 1 goto :TRYROUTER
:TRYROUTER
ECHO FAILURE!
ECHO Lets try pinging the router....
ping -n 2 192.168.1.1|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :ROUTERSUCCESS
IF ERRORLEVEL 1 goto :NETDOWN
:ROUTERSUCCESS
ECHO It appears that you can reach the router, but internet is unreachable.
goto :FAILURE
:NETDOWN
ECHO FAILURE!
ECHO It appears that you having network issues, the router cannot be reached.
goto :FAILURE
:SUCCESSDNS
ECHO It appears that you are having DNS issues.
goto :FAILURE
:SUCCESS
ECHO You have an active Internet connection
pause
goto END
:SUCCESS2
ECHO You have an active internet connection but some packet loss was detected.
pause
goto :END
:FAILURE
ECHO You do not have an active Internet connection
pause
goto :END
:END