As dbenham mentioned, it's a good idea to pass multi line strings by reference.
But if you really need to pass them by value this is also possible.
The problem is to access them.
Here is an adapted variant of How to receive even the strangest command line parameters?.
@echo off
setlocal DisableExtensions DisableDelayedExpansion
REM Write the complete parameter to a temp file
@echo on
@(for %%A in (%%A) do (
@goto :break
REM # %1 #
REM
)) > param.tmp
:break
@echo off
REM receive all lines from the temp file and store them in an array
setlocal EnableExtensions
set cnt=0
for /F "skip=3 delims=" %%a in (param.tmp) DO (
set /a cnt+=1
setlocal EnableDelayedExpansion
for /F %%n in ( "!cnt!" ) do (
setlocal DisableDelayedExpansion
set "param%%n=%%a"
)
)
setlocal EnableDelayedExpansion
set \n=^
REM Build the \n variable with a linefeed character, the two empty lines are required
REM Build from the array a single parameter
set /a cnt-=2
set "param1=!param1:~6!" REM Remove the 'REM #' from the first line
set "param%cnt%=!param%cnt%:~0,-3!" REM Remove the trailing '#' from the last line
set "param="
for /L %%n in (1 1 !cnt!) do (
if %%n GTR 1 set "param=!param!!\n!"
set "param=!param!!param%%n:~1!"
)
echo The param is: '!param!'
Sample call from the console (the empty lines are required!):
test.bat ^"hello^
Line2^
Line3"
Carriage returns can't be accessed, as they are always removed by cmd.exe
But there are still problems, when suboptimal content is used.