windows batch file with goto command not working

前端 未结 2 918
滥情空心
滥情空心 2020-12-01 17:40

I have a problem with GOTO command and affiliated labels.

Facts: Given a bunch of files from a folder (they are log errors) I need to open them and check if they co

2条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 18:20

    Comments / Remarks

    :: This is a REMark

    A colon (:), which is actually the LABEL tag, can be used for comments instead of REM, by doubling it (::), except within parentheses (i.e. except within a FOR loop).

    Using a double-label within a loop can cause the batch script to fail, but ONLY if:

    • The double-label is followed by a second double-label on the next line
    • The double-label is followed by an empty line on the next line
    • The double-label is the last line in the loop

    In other words: if used within a loop, the double-label must be followed by a line which contains normal (i.e. valid) syntax. Even a single-label is valid syntax.

    This error never occurs if the double-label is replaced with REM.

    The error arising from a double-label occurs because CMD.EXE interprets :: as a drive letter (like C:).

提交回复
热议问题