Can't be done.
Similar to why the chown Unix command uses a colon as a separator: chown assumes usernames end with colons. Likewise, batch files have a file format.
The file format of a batch file assumes that the newline character ends a line. There is no supported escape sequence. So, what you're asking for cannot be done.
One possible workaround is if the program recognizes an escape sequence, such as recognizing \n. (JScript, supported as .js files that CScript can use, supports the unescape command. WScript.Echo(unescape("%0d0a"));
)
Another common approach to handle this is if a program supports a data stream, which could be a specified filename or the "standard input" stream. Newline characters/sequences can be provided to a program that way.
Those approaches are used by multiple programs. I'm not offhand recalling any way to just have batch ignore a newline character, nor any other standardized way to try to encode that character in a way that all/most programs will recognize the character(s) that you're trying to refer to.
It can be done. See this answer How can you echo a newline in batch files?
– DavidPostill – 2017-08-24T09:51:48.263@DavidPostill – Hi David, please see history of my answer. It can be done with
echo
, but I removed that from the answer, because it cannot be done with regular exe files and the OP does not care aboutecho
.echo
seems to be an exception. I have made many tests and searching before reverting the answer to current that it cannot be done. However, I have seen this to be done regularly by developers when going through P/Invoke. That way it works and this is what I advice in the answer. It seems that the breaking part is parsing of command line incmd
. – miroxlav – 2017-08-24T10:00:49.883Fair enough. I don't have an exe file I could test it with. – DavidPostill – 2017-08-24T10:09:26.283
@DavidPostill – you can still test it with
cmd /c echo ......
:) – miroxlav – 2017-08-24T11:10:40.767@DavidPostill It still can be done, your first link points into the right direction. See my answer
– jeb – 2020-01-24T10:28:54.320