Break命令在.bat文件中不执行任何操作

时间:2023-01-13 16:02:40

break /? says:
If Command Extensions are enabled, and running on the Windows platform, then the BREAK command will enter a hard coded breakpoint if being debugged by a debugger.

cmd /? says:
Command Extensions are enabled by default. (I learned that we can manually enable/disable by cmd /E:ON/OFF)

Since Command Extensions are enabled by default, then

休息/?说:如果启用了Command Extensions并在Windows平台上运行,那么BREAK命令将在调试器调试时输入硬编码断点。 cmd /?说:默认情况下启用命令扩展。 (我了解到我们可以通过cmd / E手动启用/禁用:ON / OFF)由于默认情况下启用了Command Extensions,

for /f "tokens=*" %%f in (textfile.txt) do (
    echo %%f
    break
)

should work, but unfortunately not.

Why it's not working? What is the proper way to use break to set a breakpoint in the for loop?
Thanks in advance.

应该工作,但不幸的是没有。为什么它不起作用?使用break在for循环中设置断点的正确方法是什么?提前致谢。

1 个解决方案

#1


1  

If Command Extensions are enabled, and running on the Windows platform, then the BREAK command will enter a hard coded breakpoint if being debugged by a debugger.

如果启用了Command Extensions并在Windows平台上运行,则BREAK命令将在调试器调试时输入硬编码断点。

You're not debugging it so naturally nothing happens. More info: breakpoint definition.
To exit from a loop use goto to an outside label:

你没有调试它,所以没有任何反应。更多信息:断点定义。要退出循环,请使用goto到外部标签:

for /f "tokens=*" %%f in (textfile.txt) do (
    echo %%f
    goto break
)
:break

#1


1  

If Command Extensions are enabled, and running on the Windows platform, then the BREAK command will enter a hard coded breakpoint if being debugged by a debugger.

如果启用了Command Extensions并在Windows平台上运行,则BREAK命令将在调试器调试时输入硬编码断点。

You're not debugging it so naturally nothing happens. More info: breakpoint definition.
To exit from a loop use goto to an outside label:

你没有调试它,所以没有任何反应。更多信息:断点定义。要退出循环,请使用goto到外部标签:

for /f "tokens=*" %%f in (textfile.txt) do (
    echo %%f
    goto break
)
:break