Computing Staff
  • 0

Continuous Internet Connection Monitor – DOS Bat

  • 0

I need help in creating a DOS bat that will continuously monitor my internet connection and only append a Internetstatus.txt file if there is an error message, that will list the “Date/Time” stamp followed by the “URL” and finally a message, “…Connection Failed”. The script will re-run every 15 seconds.
Thanks in advance for any assistance you may offer,
Don

Here is my logic:
Ping my Wi-Fi router 192.168.0.1
If no connection
Append Internetstatus.txt file with “Date/Time” “URL” “Wi-Fi Router Connection Failed”
Else
Ping my Cable Modem XXX.XXX.XXX.XXX
If no connection
Append Internetstatus.txt file with “Date/Time” “URL” Cable Modem Connection Failed”
Else
Ping my Internet Service Provider’s Server XXX.XXX.XXX.XXX
If no connection
Append Internetstatus.txt file with “Date/Time” “URL” “ISP Connection Failed”
Else
Ping my DNS Server XXX.XXX.XXX.XXX
If no connection
Append Internetstatus.txt file with “Date/Time” URL” “DNS Server Connection Failed”
Else
Ping GOOGLE.com
If no connection
Append Internetstatus.txt with “Date/Time” “URL” Google Connection Failed”

Wait 14 seconds and restart this process

Share

1 Answer

  1. Sorry for this non-answer, but I would start pinging from top down, to save overhead (not that it amounts to much, but…). I would ping Google first. THEN: If that succeeds, then presumably you won’t need to ping the underlings, as they are all awake and doing their jobs and your program can sleep., ELSE: Then I would work downwards from there if Google failed: DNS, then ISP, etc.
    Altenatively, there is an “event-driven” option for schtasks on win7+, but not sure about Vista, which will run a task based on events (use switch: /create /MO ONEVENTS: “Xpath event query string”) which would be ideal for your purposes, but that’s all I know at this point, not having worked much with seven. Use Google “xpath event query string” or wait for someone competent (Razor, anyone? hint?) to help here. I figure if any live TCP/IP connection drops, an event would be triggered, and this setup would save a lot of overhead of constanly monitoring tcip connections “manually”. Meantime, I’m curious myself, so I’ll keep up.

    • 0