本帖最后由 路过 于 2017-7-13 23:50 编辑
看样子你的操作系统是WIN7以上,能够显示中文结果。- @echo off&chcp 936
- setlocal enabledelayedexpansion
- set "text1=无法访问目标"
- set "text2=请求超时"
- set ip=192.168.1.1
-
- :loop
- for /f "tokens=*" %%a in ('ping /n 1 %ip% 2^>nul') do (set q=%%a
- echo;%%a|find /i "%text1%" && echo;%date:~0,4%年%date:~5,2%月%date:~8,2%日 %time:~0,2%点%time:~3,2%分 %ip% "%text1%">>Timeout.txt
- echo;%%a|find /i "%text2%" && echo;%date:~0,4%年%date:~5,2%月%date:~8,2%日 %time:~0,2%点%time:~3,2%分 %ip% "%text2%">>Timeout.txt
- if "!q:ttl=!" neq "!q!" (echo;%date:~0,4%年%date:~5,2%月%date:~8,2%日 %time:~0,2%点%time:~3,2%分 %%a>>Log.txt)
- )
- ping/n 60 127.0>nul
- goto loop
复制代码
|