rem 利用for读取ping命令返回结果;
for /f "delims=" %%i in ('ping
www.21cn.com') do (
rem 初始化ret(这里就是清空的意思);
set ret=
rem" if defined %%a"就是检查是否存在对应的变量%%a,如果存在就用变量值替换;(变量就是我们要翻译的单词,而变量值已经设置为对应的中文意思)
for %%a in (%%i) do if defined %%a (set ret=!ret!!%%a!) else set ret=!ret! %%a
rem 因为时间在这里不好翻译,所以直接采用这种替代的办法。
if not "!ret!"=="" (set ret=!ret:time=时间! && echo !ret!) else echo.
)
rem Read the ping command return result using for;
for /f "delims=" %%i in ('ping
www.21cn.com') do (
rem Initialize ret (here it means clearing);
set ret=
rem "if defined %%a" is to check whether the corresponding variable %%a exists, and if it exists, replace it with the variable value; (the variable is the word we want to translate, and the variable value has been set to the corresponding Chinese meaning)
for %%a in (%%i) do if defined %%a (set ret=!ret!!%%a!) else set ret=!ret! %%a
rem Because the time is not easy to translate here, so directly adopt this alternative method.
if not "!ret!"=="" (set ret=!ret:time=时间! && echo !ret!) else echo.
)