How To Write Comment Block In Batch File MS-DOS?


Windows MS-DOS very useful programming environment for Windows family operating system. In order to complete jobs easier, faster, and with less error system administrators generally use batch scripts. In order to remember or understand commands and functions written to the batch script we generally use comments or comment block. In this tutorial, we will look at how to create comments.

Single Line Comment

We will start by showing a single line comment. rem is the keyword used by MS-DOS in order t specify the comment line. The comment line will start with rem keyword and we have to put a single space to start the comment part. In this example, we will write comment This is comment . As we know comments are not executed or interpreted like other commands. They are just text to explain code.

rem This is comment

Multiple Line or Block Comment

We can also provide multi line or block comment by using multiple rem keyword in a row like below. Below we will use multiple rem keyword which will look like a block of comment but in reality they are multiple single line comments.

rem This is a comment
rem This is a comment too
rem This too

:: Comment Line

We can also use :: as comment sign like rem . We will use :: as line starter and write a comment after that. We can also use it multiple lines for block comments too.

:: This is a comment
:: This is a comment too

LEARN MORE  How To Pause and Resume Powershell and Cmd Scripts In Windows With Examples?

4 thoughts on “How To Write Comment Block In Batch File MS-DOS?”

  1. Greate post. Keep posting such kind of info on your page.
    Im really impressed by your blog.[X-N-E-W-L-I-N-S-P-I-N-X]Hello there,
    You’ve done an incredible job. I’ll certainly digg it and in my view suggest to my friends.
    I am sure they will be benefited from this web site.

    Reply
  2. Extremely effective and excellent, and providing such information, all can provide a passionate and worthwhile world, and has special knowledge about the subject matter.

    Reply
  3. To me, the title is misleading. Adding a line comment mark to every line is not really a “Block comment”, although some programmers now use it that way. A block comment is one with a start and end mark so that you don’t have to worry about adding it to every single line for a more readable comment and for longer comments. For example, in SQL and a few other languages the /* to start the comment and then end the comment with */ truly gives you a block comment where you don’t have to remember to add special code for every hard return. If it was your intention to get more clicks by adding a title to have people come look who already knew how to do a line comment, then you succeeded.

    Reply
  4. Hello There. I found your blog using msn. This is a very well written article.
    I will make sure to bookmark it and come back to read more of
    your useful information. Thanks for the post. I will certainly return.

    Reply

Leave a Reply to Cat Hat Cancel reply