开发者

batch file for sporadic internet connection

i've seen pingers and auto redials when theres a request time out.

problem: but im having a hard time researching the 'counter or increment' part.

idea: heres how it should be:

start pinging continuously while connected to internet, otherwise count (or accumulate) request time out until 1min or 60 request time out, if connection went back after request time out & less than '60 times request time out',reset the 'request time out counter' to zero if request time out reached 60x : run another batch 开发者_运维问答or reconnect re-dial up. loop to internet connection pinging

the closest that i saw: (but for some reason its not working on my xp)

@echo off
setLocal EnableDelayedExpansion

:loop

ping -n 2 10.174.10.48 >> log
find /i "Reply" < log > nul
if not errorlevel 1 type nul > log & goto :loop

for /f "tokens=1" %%a in ('find /c /i "Request timed out" ^< log') do (
if %%a geq 10 echo file.exe && type nul > log
)
goto :loop

source: http://www.computing.net/answers/programming/ping-bat-file/16605.html

credits to the original poster. thank you


It would be good to know why the above script is not working. Because possibly other solutions will also not work. If you use a non-English version of windows, you need to replace the text "Reply".

I think the following should work. It just implements the counter. But you can try yourself how you need to set the counter to execute the script after 60 seconds.

@echo off

:reset
set count=0
:loop

ping -n 2 10.174.10.48 | find /i "Reply"  
if not errorlevel 1 goto :reset

set /A count=%count%+1
if %count% lss 100 got :loop

call reconnect

goto :reset
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜