无限循环 Windows 批处理文件?

Infinite loop Windows batch file?

我在 Linux 中 运行 循环了这个 bash 脚本,Windows 相当于这样做的是什么?

while ./process.sh; do sleep 1; done

我有一个 windows 批处理文件,我想 运行 只要 return 代码为 0

我想你正在寻找这样的东西:

:LOOP
timeout /T 1 /NOBREAK
call "\path\to\your\process.sh\equivalent\batch\file"
if not ErrorLevel 1 goto :LOOP

注意:这在命令行上不起作用。您需要将此代码放入批处理文件中。

cmd /q /e /c"for /l %%a in () do (call process.cmd || exit) & >nul timeout /t 1"

如果您想从命令行测试它,请将 %%a 更改为 %a