Safe REM with ampersand
Posted: 14 Jan 2016 09:03
Hi,
from a SO topic How to reliably use `rem` within a command line without ignoring adjacent commands?.
Is there a way for a safe REM which executes an adjacent command.
Simple, but can fail when a file named REM exists
There seems also a difference if there is an ampersand or not.
But my tests shows that these sample works always
from a SO topic How to reliably use `rem` within a command line without ignoring adjacent commands?.
Is there a way for a safe REM which executes an adjacent command.
Simple, but can fail when a file named REM exists
Code: Select all
REM. comment & echo My text
There seems also a difference if there is an ampersand or not.
Code: Select all
REM^;\..\x.bat & This works
REM But not the next line, it starts x.bat in the current directory
REM^;\..\x.bat
But my tests shows that these sample works always
Code: Select all
@echo off
echo 1
REM^= \..\x.bat
echo 2
REM^/ \..\x.bat
echo 3
REM^\ \..\x.bat
echo 4
REM^: \..\x.bat
REM^= \..\x.bat & echo 4
REM^/ \..\x.bat & echo 5
REM^\ \..\x.bat & echo 6
REM^: \..\x.bat & echo 7