OK, let's have a look at the various lines of my batch file:
1 @echo off
2 :again
3 ping
www.google.com | find /i "bytes=" > nul && goto Connected
4 ping localhost -n 60 > nul
5 goto again
6 :Connected
7 "c:\Program Files\MyApp\mailcheck.exe"
Line 1: This line prevents the commands from appearing on
the screen while the batch file runs.
Line2: This is a label that is used by Line 5.
Line3: This line consists of three components:
a) It pings google.
b) It monitors the reply it gets.
c) If the reply contains the string "bytes=" then it jumps to the label
"Connected". This string is generated only when your PC gets a
reply from Google. It therefore tells you that your Internet
connection is live.
Line4: This line causes the batch file to pause for about one minute.
Line5: Go back to the label "Again".
Line 6: This is where the batch file resumes when your
Internet connection is live.
Line 7: This is your EMail checking command.