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

后端 未结 9 1206
后悔当初
后悔当初 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:28

    Here is the issue and how to fix it. The issue is a bug or a feature in DOS batch cmd program. First the clear problem statement. If you have a DOS batch file with target labels like, ":dothis", and at the end of the label you do not have space then the batch file will not work if the line ending are UNIX line endings. This means you have to run unix2dos on the file before you can use it.

    The root cause is the DOS command line processor, (shell program), takes the UNIX end-of-line character as part of the label. Since the go to part never uses this as the label, it is never found since such a label truly does not exist. The solution is to put an extra space at the end of each target label, or even better every line. Now UNIX end of lines do not come to play since the space acts as the separator and it all works.

提交回复
热议问题