View Poll Results: Do you think this script is useful?
- 3. You may not vote on this poll
Yes- It is useful to me just like it is
Yes- But it needs more functionality.
No- But with some work it could be
No- Why on Earth did you do this?
July 27th, 2003, 01:13 AM #1
A handy batch file to check network connectivity.
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]
@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 220.127.116.11|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
July 27th, 2003, 01:41 AM #2
- Join Date
- Jun 2002
- Blog Entries
Fun! I suppose I could modify some of that to suit my own needs/wants/desires....
ECHO You do not have an active Internet connection
ECHO Hey Moron, it still doesn't work. quit tryin' !
goto :ENDthis post contains small bits of intelligence culminating to the appearance of wisdom.
July 27th, 2003, 01:44 AM #3
You could also change the responses/actions based on username if you used %username% string.My computer is bigger than yours!
July 27th, 2003, 09:23 AM #4
February 24th, 2009, 07:05 PM #5
- Join Date
- Feb 2009
Thanks a lot man,
It really is working. I can now use this batch file to autoshut down whenever the power goes off. The router works on the mains and the PC onUPS. so the PC will get time to shut down.
Thanks once again
March 30th, 2011, 11:11 AM #6
- Join Date
- Mar 2011
Yes, I know this is an old thread, but I wonder if someone could help me with this too?
I would like to have a batch file that stays running in the background and notifies with a message everytime there is a lan issue?
March 30th, 2011, 01:08 PM #7
I get along with the Command Prompt and a few basic commands. I've always been able to get whatever information I need from those.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)