输入框换行?

Line break in an input box?

我写了一个批处理脚本,其中需要一个 InputBox,首先这是代码行:

powershell -Command "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox('Enter your command: [*here i want a line break*] Example commands: [*and here i want a line break*] example command', 'Input box example')}" > %TEMP%\out.tmp

如何在此处插入换行符?请帮助我,现在搜索几个小时。

亲切的问候, jcjms

您可以这样做:

powershell -Command "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox(\"Enter your command: `r`nExample commands: `r`nexample command\", 'Input box example')}"

powershell -Command "& {Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox('Enter your command: {0}Example commands: {0}example command' -f [environment]::Newline, 'Input box example')}"


正如 评论的那样。
无需将命令括在 & {..} 中。您可以简单地在命令周围加上引号:

powershell -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox(\"Enter your command: `r`nExample commands: `r`nexample command\", 'Input box example')"

powershell -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::InputBox('Enter your command: {0}Example commands: {0}example command' -f [environment]::Newline, 'Input box example')"