What does :: (double colon) mean in DOS batch files?

后端 未结 5 771
半阙折子戏
半阙折子戏 2020-11-27 04:58

I found this program http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/

But I don\'t know what does the line

:: datetime.bat
<         


        
5条回答
  •  甜味超标
    2020-11-27 05:09

    :: is a label (also, inaccurately, known in the wild by comment label) can be, in practice, considered a comment just as REM is, as it is an "un-goto-able" label.

    There are some differences between REM and ::, though. The main ones are:

    • With ECHO ON a REM line is shown but not a line commented with ::
    • A :: can execute a line end caret (that is, a ^ at the end of a line starting with :: makes the next line also a comment):

      :: This is a comment^
      echo but watch out because this line is a comment too
      
    • Labels and :: have a special logic and can cause problems in parentheses blocks - take care when using them inside ( ). Example:

      for %%D in (hi) do (
          echo Before...
          :: My comment
          :: Some other comment
          echo After...
      )
      

      Outputs:

      Before ...
      The system cannot find the drive specified.
      After...
      

提交回复
热议问题