Comment In Windows Batch File
Is there any syntax for multi-line code block comment in Windows batch script? I know REM and:: for line-by-line comment, but it is not efficient to comment a code block. Dec 11, 2014 Code block comment syntax in Windows batch script. Ask Question -1. Is there any syntax for multi-line code block comment in Windows batch script? Browse other questions tagged windows batch-file syntax comments or ask your own question. 4 years, 6 months ago. 4 years, 6 months ago.
Pony ginuwine mp3 download. It’s always a good practice to add comments or documentation for the scripts which are created. This is required for maintenance of the scripts to understand what the script actually does.
For example, consider the following piece of code which has no form of comments. If any average person who has not developed the following script tries to understand the script, it would take a lot of time for that person to understand what the script actually does.
Comments Using the Rem Statement
There are two ways to create comments in Batch Script; one is via the Rem command. Any text which follows the Rem statement will be treated as comments and will not be executed. Following is the general syntax of this statement.
Syntax
where ‘Remarks’ is the comments which needs to be added.
Comment In Windows Batch File
The following example shows a simple way the Rem command can be used.
Example
Output
The above command produces the following output. You will notice that the line with the Rem statement will not be executed.
Comments Using the :: Statement
Multiline Comment In Windows Batch File
The other way to create comments in Batch Script is via the :: command. Any text which follows the :: statement will be treated as comments and will not be executed. Following is the general syntax of this statement.
Syntax
where ‘Remarks’ is the comment which needs to be added.
The following example shows a simple way the Rem command can be used.
Example
Output
The above command produces the following output. You will notice that the line with the :: statement will not be executed.
Note − If you have too many lines of Rem, it could slow down the code, because in the end each line of code in the batch file still needs to be executed.
Let’s look at the example of the large script we saw at the beginning of this topic and see how it looks when documentation is added to it.
You can now see that the code has become more understandable to users who have not developed the code and hence is more maintainable.