DOS多行批处理命令。如何在参数之间添加注释?

时间:2015-02-24 13:52:29

标签: batch-file command-line cmd command-line-arguments

我想添加以下评论:

makecert -r ^        // This means SelfSigned
         -pe ^       // Private key is exportable
         -a sha512 ^ // The algoritm
         ...

这可能吗?怎么样?

1 个答案:

答案 0 :(得分:2)

没有官方的,但有一个简单而且非常有效的黑客 - 使用未定义的变量。添加至少一个=以保证内容不能是有效的变量名,因为该字符不能用于变量名。我在开头和结尾使用一个只是为了对称。此外,评论不能包含%:。最后,行继续^字符必须是行中的最后一个字符。

makecert -r        %= This means SelfSigned     =% ^
         -pe       %= Private key is exportable =% ^
         -a sha512 %= The algoritm              =% ^
         ...

注意 - 这仅适用于批处理脚本。它不能在命令行中使用。