📜  If ERRORLEVEL - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:48.067000             🧑  作者: Mango

代码示例2
:Ping
for /f "tokens=* skip=2" %%A in ('ping %host% -n 1 ^& call echo %%^^errorlevel%%^>error.level') do (
    set /p elv=<"error.level" 
    if not !elv!==0 (echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A>>%logfile_fail%)
    echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A>>%logfile%
    echo elv %elv% %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A
    timeout 1 >NUL 
    GOTO Ping
)