寫了一個測試版. 除了輸出文件用日期命名還沒有解決外,其餘功能已實現.
代碼如下:- @echo off
- set pingadd=www.youraddress.com
- set log="%userprofile%\Desktop\pinglog.txt"
- set percentage=20
- :loop
- for /f "tokens=8 skip=8 delims=():=, " %%i in ('ping %pingadd%') do set lostper=%%i
-
- set /a lostnum=%lostper:~0,-1%
-
- if %lostnum% gtr %percentage% (
- echo %date% %time% ping %pingadd% loss packets over %percentage% >>%log%
- )else (
- goto :loop
- )
复制代码
|