[英]Windows Command Prompt: How to pass multi-line string parameters
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?
有没有办法传递多行字符串参数?
Your question is duplicate to - Windows: How to specify multiline command on command prompt?您的问题与 - Windows:如何在命令提示符下指定多行命令重复?
In the Windows Command Prompt the ^ is used to escape the next character on the command line.
在 Windows 命令提示符中,^ 用于转义命令行上的下一个字符。
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
.此例程将多行写入
F:\\Backup_Info
驱动器和目录中的文本文件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 . . .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.