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

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

    I encountered a similar issue just now with a .cmd file and Windows 8. The solution was to change all line endings to CR+LF DOS style. The issue was confusing because the batch file mostly worked and rearranging lines changed the effect.

    The .cmd file looked like:

    call:function_A "..\..\folderA\"
    call:function_B "..\..\folderB\"
    call:function_C "..\..\folderC\"
    call:function_D "..\..\folderD\"
    goto:eof
    
    :function_A
    rem do stuff
    goto:eof
    
    ...etc...
    

    Function C would cause error "The system cannot find the batch label specified". Strangely it could go away by rearranging the calls. Changing line endings from 0x0A to 0x0D0A seems to have fixed it.

    Perhaps VonC meant "the batch file must use CRLF line endings".

提交回复
热议问题