Sar*_*sal 3 windows batch-file infinite-loop
我有以下批处理脚本用于运行目录中的所有文件。但是,此脚本是一个无限循环并不断重复。有没有办法在完成最后一个批处理文件时停止脚本,以下是我的脚本
@echo off
for /R %%x in (*.bat) do (
call "%%x"
)
pause
Run Code Online (Sandbox Code Playgroud)
由于您将此脚本包含在当前目录中,因此它与其他脚本一起运行:递归/无限调用。
要么将此脚本向上一级, cd 放在 bat 文件的目录中,然后调用它 ..\yourscript.bat
或者您可以过滤掉循环中的当前脚本:
@echo off
for /R %%x in (*.bat) do (
if not "%%x" == "%~0" call "%%x"
)
Run Code Online (Sandbox Code Playgroud)