English 中文(简体)
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




相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签