osc*_*tin 5 windows windows-7 batch-file
我正在使用 CLI 并传递一个开关和参数,如下所示,其中参数被括在其中"并包含一系列由 分隔的子参数(表达式);:
-switch "a long expression; another long expression; yet another; and hey one more"
Run Code Online (Sandbox Code Playgroud)
我想要做的是这样的事情,我可以跨多行构造字符串,而无需实际将多行字符串传递给 EXE:
-switch "very long arg; ^
another long arg; ^
yet another;
and another"
Run Code Online (Sandbox Code Playgroud)
即使这是多行,我仍然会传递上面的单行字符串。
更新:当我输入此内容时,我刚刚发现了一种让它发挥作用的技巧:
set myswitch=a long expression; ^
another long expression; ^
yet another; ^
and hey one more
-switch "%myswitch%"
Run Code Online (Sandbox Code Playgroud)
它有效,但我想要一种更内联的方法,如我之前的示例所示。无论如何要在 Windows 7 批处理文件中实现这一点吗?(inb4需要升级到Windows 10)
为什么不:set "myswitch=strings"
\nset "myswitch=%var% more strings"
\n\n这如何帮助我构建跨多行的命令行字符串,并且比我的 OP 中的“黑客”版本更少笨重的语法?\xe2\x80\x93 振荡cretin 7 分钟前
\n
set "myswitch=a long expression; "\nset "myswitch=%myswitch% another long expression; "\nset "myswitch=%myswitch% yet another; and hey one more"\n\nexec -switch %myswitch%\nRun Code Online (Sandbox Code Playgroud)\nset myswitch=a long expression; ^\nanother long expression; ^\nyet another; ^\nand hey one more\n-switch "%myswitch%"\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
13404 次 |
| 最近记录: |