@ECHO OFF
:a
ping -n 31 127.1>nul
SET /a n=0
FOR /l %%i in (1,1,4) do (
ping -n 1 192.168.0.245>nul
if %errorlevel% EQU 0 (SET /a n+=1)
)
IF %n% EQU 4 (START start.bat&GOTO a) else (GOTO a)
PAUSE
30秒检测一次.
@echo off
echo 正在测试是否可以ping通主机XXX.XXX.XXX.XXX
:again
ping XXX.XXX.XXX.XXX >nul
if %errorlevel% EQU 0 goto bb
if %errorlevel% EQU 1 goto aa
:aa start "无法ping通" "D:\test\foxitReader.exe"
goto again
:bb
goto again
pause
@echo off
ping 192.168.0.245|find "100%"
if errorlevel 0 start.bat
@echo off
:begin
ping 192.168.0.245|find /i "ttl" &&goto begin ||start.bat