How to "comment-out" (add comment) in a batch/cmd?

user1397044 picture user1397044 · Jun 29, 2012 · Viewed 1.3M times · Source

I have a batch file that runs several python scripts that do table modifications.

  1. I want to have users comment out the 1-2 python scripts that they don't want to run, rather than removing them from the batch file (so the next user knows these scripts exist as options!)

  2. I also want to add comments to bring to their attention specifically the variables they need to update in the Batch file before they run it. I see that I can use REM. But it looks like that's more for updating the user with progress after they've run it.

Is there a syntax for more appropriately adding a comment?

Answer

T.Todua picture T.Todua · May 30, 2013

Use :: or REM

::   commenttttttttttt
REM  commenttttttttttt

BUT (as people noted):

  • :: doesn't work inline; add & character:
    your commands here & :: commenttttttttttt
  • Inside nested parts (IF/ELSE, FOR loops, etc...) use :: line should be followed with normal line, otherwise it gives error (use REM there).
  • :: may also fail within setlocal ENABLEDELAYEDEXPANSION