Why “The system cannot find the batch label specified” is thrown even if label exists?

后端 未结 9 1203
后悔当初
后悔当初 2020-11-30 02:48

While running a batch file in Windows XP I have found randomly occurring error message:

The system cannot find the batch label specified name_of_label

9条回答
  •  無奈伤痛
    2020-11-30 03:23

    There are multiple possible ways to get the error.

    1. Described by VonC - Wrong line endings, LF instead of CR/LF

    2. Obscure long lines (if that happens accidential, your code is incredible worse)

    3. Direct start another batch after calling a function.
      Sample:

      @echo off
      call :func
      echo back from second
      exit /b
      :func second.bat echo NEVER COME BACK HERE
      This unexpectedly tries to goto to the label :func in second.bat.
      But this can be (mis)-used to directly call labels in another batch file

    This is the described behaviour of the answer of Marshal

提交回复
热议问题