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?
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With