Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 433
randacun Avatar asked Aug 14 '12 07:08

randacun


People also ask

How do I create a multi line command in CMD?

The Windows command prompt (cmd.exe) allows the ^ (Shift + 6) character to be used to indicate line continuation. It can be used both from the normal command prompt (which will actually prompt the user for more input if used) and within a batch file.

What is %% A in command line?

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.


2 Answers

Your question is duplicate to - Windows: How to specify multiline command on command prompt?

In the Windows Command Prompt the ^ is used to escape the next character on the command line.

For example, (the More? being a prompt):

C:\>cd "c:\Program Files" ^ More? "\Common Files"  C:\>MyProgram "This is a " ^   More? "multiline text" parameter2 
like image 137
Dor Cohen Avatar answered Dec 24 '22 08:12

Dor Cohen


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 
like image 26
Barry Lovell Avatar answered Dec 24 '22 09:12

Barry Lovell