Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
835 views
in Technique[技术] by (71.8m points)

batch-file - 如何在批处理/ cmd中“注释掉”(添加注释)?(How to “comment-out” (add comment) in a batch/cmd?)

I have a batch file that runs several python scripts that do table modifications. (我有一个批处理文件,它运行几个进行表修改的python脚本。)

  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!) (我想让用户注释掉他们不想运行的1-2个python脚本,而不是从批处理文件中删除它们(所以下一个用户知道这些脚本作为选项存在!))

  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 . (我看到我可以使用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? (是否有更适当添加评论的语法?)

  ask by user1397044 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use :: or REM (使用::REM)

::   commenttttttttttt
REM  commenttttttttttt

BUT (as people noted): (但是(正如人们所说):)

  • If you use inline, you need to add & character: (如果使用内联,则需要添加&字符:)
    your commands here & :: commenttttttttttt
  • Inside nested logic ( IF/ELSE , FOR loops, etc...) use REM because :: gives an error. (嵌套逻辑( IF/ELSEFOR循环等)内部使用REM因为::给出错误。)
  • :: may fail within setlocal ENABLEDELAYEDEXPANSION (::可能在setlocal ENABLEDELAYEDEXPANSION失败)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...