First of all
>@echo off >for /f %%i in ('ping racer ^| find /c "(0%% loss)"') do SET MATCHES=%%i >echo %MATCHES%
Does not work. If he does not fail, he will find 0%, because he has 0%. If it fails, it does not work, because it will have a 100% loss, which means it found a 0% loss in 10 10 (loss 0%)
Was it determined by a 100% loss:
>for /f %%i in ('ping -n 1 -l 1 %pc% ^| find /c "(100%% loss)"') do SET check=%%i
The error level may be a little messed up, but it works like a charm:
>if '%check%'=='1' goto fail >if '%check%'=='0' echo %pc% is online.&goto starting
1 means he failed 0 means he succeeded
My script uses links. Going to failure will be: a failure in my script that tells me that% pc% (which I will enter to the user at the beginning) is offline and will go to another start.
>:fail >color 0c >title %pc% is offline >echo %pc% is offline >PING -n 6 127.0.0.1>nul >goto choice
Hope this helps.
Justin duijn
source share