rem main.bat @echo off for /F "eol=; tokens=1,2* delims==" %%i in (ip.TXT) do call :checkip %%i %%j 0 echo -------------------------------------------------------------- echo ----第一轮检查完毕,如果没有听到报警声,表示各IP都可以PING通---- echo ----如果有异常的IP,请再手动使用PING命令,以确认检查的正确性---- echo ---- 现在进行循环检查,每隔10000ms检查一个IP ---- echo -------------------------------------------------------------- :begin for /F "eol=; tokens=1,2* delims==" %%i in (ip.TXT) do call :checkip %%i %%j 10000 goto begin
:checkip
@echo off PING %1 -n 1 | FIND "TTL=" >NUL IF NOT ERRORLEVEL 1 ECHO %1(%2) Status OK at %TIME% IF NOT ERRORLEVEL 1 GOTO NEXT PING %1 -n 1 -w 3000 | FIND "TTL=" >NUL if %ERRORLEVEL%==1 call :send %1 %2 ELSE ECHO %1(%2) Status OK at %TIME% :Next sleep %3 goto end
:send @echo off ECHO %1(%2):::::Status ERROR at %TIME%::::: for /F "eol=;" %%i in (user.TXT) do net send %%i "Error Pinging %1(%2)." >NUL Beep 1500 500 Beep 500 500 Beep 1500 500 Beep 500 500 goto end