View Poll Results: Do you think this script is useful?

Voters
3. You may not vote on this poll
  • Yes- It is useful to me just like it is

    1 33.33%
  • Yes- But it needs more functionality.

    0 0%
  • No- But with some work it could be

    1 33.33%
  • No- Why on Earth did you do this?

    1 33.33%
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Did you try Google yet? Siliconjunkie's Avatar
    Join Date
    Feb 2003
    Location
    Buckhannon, WV
    Posts
    3,468

    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]

    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

  2. #2
    IRONyMan RedFury's Avatar
    Join Date
    Jun 2002
    Location
    MinneSOta
    Posts
    5,522
    Blog Entries
    3
    Fun! I suppose I could modify some of that to suit my own needs/wants/desires....

    :FAILURE
    ECHO You do not have an active Internet connection
    pause
    goto :END
    :FAILURE
    ECHO Hey Moron, it still doesn't work. quit tryin' !
    pause
    goto :END
    this post contains small bits of intelligence culminating to the appearance of wisdom.

    http://www.shareaproject.com/pages/p...,p,346,00.html

  3. #3
    Did you try Google yet? Siliconjunkie's Avatar
    Join Date
    Feb 2003
    Location
    Buckhannon, WV
    Posts
    3,468
    You could also change the responses/actions based on username if you used %username% string.
    My computer is bigger than yours!

  4. #4
    Ultimate Member meese's Avatar
    Join Date
    Jun 2003
    Location
    NJ
    Posts
    2,467
    Silicon,

    Nice little proggy! Thanks.

  5. #5
    Junior Member
    Join Date
    Feb 2009
    Posts
    1
    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

    --Sriram

  6. #6
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Hi,

    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?

    Much appreciated!

    Kris

  7. #7
    Member JasmineTF's Avatar
    Join Date
    Dec 2010
    Location
    Chicagoland
    Posts
    353
    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.

Quick Reply Quick Reply

If you are already a member, please login above.

What is 10 and 5 added together?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright 2014 All Enthusiast, Inc