Comment out batch file windows




















The batch language doesn't have comment blocks, though there are ways to accomplish the effect. Or, If the comment block appears at the end of the batch file, you can write EXIT at end of code and then any number of comments for your understanding. It works only because goto ignores all arguments past the first one. The proof is easy, this goto will not fail either:. This is an old topic and I'd like to add my understanding here to expand the knowledge of this interesting topic. We can treat :: as a token that as soon as CMD parser encounters the first non-blank space in a line is this :: token, it will just skip the whole line and read next line.

That's why REM should be followed by at least a blank space to be able to function as a comment for the line, while :: does not need any blank space behind it. When commenting, use :: as it's 3 times faster. An example is shown here. Only if comments are in if , use rem , as the colons could make errors, because they are a label.

For commenting line use REM or :: though :: might fail inside brackets. As noting will be parsed after the exit command you can use it to put comments at the end of the file:. More details here :. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Ask Question. Asked 9 years, 6 months ago. Active 3 months ago.

Viewed 1. I have a batch file that runs several python scripts that do table modifications. Is there a syntax for more appropriately adding a comment? Improve this question. Todua See also excellent answers here stackoverflow. Add a comment. Active Oldest Votes. Improve this answer. Todua T. The double colon :: Is the cleanest. And it can be used at the start or middle of a line! Didn't work for me when done inline like this.

To illustrate, open cmd prompt and run dir ::blah which doesn't list the contents of. Examples of how using :: labels as comments can cause difficult-to-anticipate errors. Show 13 more comments. Rob Kennedy Rob Kennedy k 20 20 gold badges silver badges bronze badges. You can now see that the code has become more understandable to users who have not developed the code and hence is more maintainable.

Batch Script - Comments Advertisements. Previous Page. Next Page. Previous Page Print Page. You can also place a comments in a batch file by starting the comment line with two colons [::] as shown below. This is the basic syntax for multiple line comments. Every line may be replaced with comments. Hence we allow multiline comments without having to use REM command before each line.

Try it out yourself! If you have a remark using the double-colon :: style inside of a FOR loop it can lead to problems, while REM never will. Your email address will not be published. Skip to content Well, we have already started with the basics and already wrote our first program in the previous discussions. Hope you followed them. If not, go back and read them before you proceed into the operators in batch files.

Just like all other scripting languages, batch files also support a very large variety of operators classified into different groups.

REM [Comment]. REM [ Comment ]. REM this is single line comment and lasts for one line only. You can end here are continue as the same.

REM you know this is the first line of comment. REM this is the second line. REM This is my hello, world program echo Hello, world!! REM This is my hello , world program. REM This is my Hello , world program. And so is this line.



0コメント

  • 1000 / 1000