I am trying to use the rem
command to place a remark in a command line that contains several commands. Here are some examples to illustrate what I mean:
echo Hello & rem.Comment & echo world!
(echo Hello & rem.Comment) & echo world!
This works perfectly fine, both echo
commands in each line are executed as I expect. The .
seems to modify the behaviour of the rem
command so that it does not treat the remaining line as comment:
Hello world!
If I placed a SPACE (or any other delimiter TAB, ,
, ;
, =
) instead of the .
, the remaining line and therefore the second echo
would be ignored (for the second example a More?
prompt appears, because the )
is part of the remark and cmd
expects a closing )
because of the (
):
Hello
I found out that beside .
, the following characters work as well: :
, /
, \
, [
, ]
and +
.
What else works is escaped delimiters: ^
SPACE, ^
TAB, ^,
, ^;
and ^=
.
Nevertheless, is there a secure and reliable way to do that?
I would be very glad about a solution that works for both command prompt and batch-files.
According to this external reference, the familiar syntax echo.
for returning a blank line fails under certain circumstances, hence using echo(
is recommended as this is the only reliable method.
However, for rem
, the (
does not work, everything after rem(
is not recognised as a command.
Since I am aware of a weird bug of the rem
command in Windows XP (reference this external link: rem %~
), I am interested in a solution that applies to Windows Vista, Windows 7 or higher.