Windows batch comment out line
RobKennedy as I read the answer, it does not read anything after the ::, where everything after REM is read. If the command interpreter stops reading , James, then it would never execute any more of the file. It obviously needs to continue reading to discover where the comment ends and where next line of the file begins.
It has to do that with :: and rem equally. RobKennedy, I also thought it was implied that it only applied to the line the command was on. Show 3 more comments. Multi line comments If there are large number of lines you want to comment out then it will be better if you can make multi line comments rather than commenting out every line. See this post by Rob van der Woude on comment blocks : The batch language doesn't have comment blocks, though there are ways to accomplish the effect.
And so is this line. And this one Somnath Muluk Somnath Muluk Important: This statement with comment looks intuitively correct: goto error1 :: handling the error but it is not a valid use of the comment. The proof is easy, this goto will not fail either: goto error1 handling the error But similar attempt color 17 :: grey on blue fails executing the command due to 4 arguments unknown to the color command: :: , grey , on , blue.
Community Bot 1 1 1 silver badge. From other answers, it seems that the ampersand is not needed? Snaptastic — The other answers are actually wrong in this point, see my recent edit. This seems to be the correct way; It even gets highlighted as comment in my IDE. In those cases, use REM instead. Pikamander2 Pikamander2 5, 3 3 gold badges 39 39 silver badges 56 56 bronze badges.
This is based on T. Todua's answer. I felt that their answer was good but left out some important details, but they rolled back my edit, so I'm turning my revision into its own answer.
You can add comments to the end of a batch file with this syntax: echo off :: Start of code This can be only at the end of batch files Just make sure you never use a closing parentheses. You can use :: or rem for comments. An example is shown here Only if comments are in if , use rem , as the colons could make errors, because they are a label. Anic17 Anic17 4 4 silver badges 14 14 bronze badges. Commenting a line For commenting line use REM or :: though :: might fail inside brackets within delayed expansion lines starting with!
Im really impressed by your blog. I am sure they will be benefited from this web site. Extremely effective and excellent, and providing such information, all can provide a passionate and worthwhile world, and has special knowledge about the subject matter. To me, the title is misleading. 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.
Hello There. Is this page helpful? Please rate your experience Yes No. Any additional feedback? Note This command is internal to the command-line interpreter, cmd. Submit and view feedback for This product This page. Previous Topics. Split string by delimiter. Find String. Recent Updates. How to manage users in Mysql? Cursor in Mysql of Code Template by.
Top authors Hot Updates. J2EE Technologies Tutorial. Lightsail ssh not working after Ubuntu Upgrade How to Copy letsencrypt ssl certificate to another server in 3 Steps? Do you want to delete content. Do you want to remove selected book from favorite books. Add a Lesson.
Edit a Lesson.
0コメント