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.
)
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.
)
