Windows Command Prompt: How to pass multi-line string parameters

Viewed 27340

I have a program that accepts a string parameter. I create a batch file that executes the program and a multiline string paramter. I also have a second parameter after the multiline string.

C:\>MyProgram "This is a
multiline text" parameter2

When I run this, only the first line of string is included in the command and the subsequent lines and the second parameter are ignored. Is there any way to pass multiline string parameters?

3 Answers

This routine will write multiple lines to text file ASM.txt in the drive and directory of F:\Backup_Info. Note that it will give a line space using the space then ^ symbol as shown, a line space is required between each statement:

(echo To Do is to Understand^

Who Dares Wins^

 ^

Baz) > F:\Backup_Info\ASM.txt

You can save ^ 's output as a variable

set br= ^
<</br (newline)>>
<</br>>

example:

@echo off
setlocal enableExtensions enableDelayedExpansion
rem cd /D "%~dp0"
set br= ^


rem br, can't be saved to a var. by using %..%;


set "t=t1!br!t2!br!t3"

for /f "usebackq tokens=* delims=" %%q in ('!t!') do (
    echo %%q
)


:scIn
rem endlocal
pause
rem exit /b

; output:

t1
t2
t3
Press any key to continue . . .
Related