1

I wrote a batch script in which an InputBox is required, first of all this is the code line:

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

How do I insert a line break there? Pls help me, searching for hours now.

Kind regards, jcjms

1
  • jcjms, I hace removed some of your tags. This question is relevant only to a small part of your [powershell] code, and to designing the [inputbox] with a particular layout. It has nothing whatsover to do with a [batch-file], the [command-prompt], or a [messagebox]. Please be more considerate when assigning tags to your questions. Commented Nov 27, 2021 at 13:51

1 Answer 1

3

You can do this like:

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

or

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')}"

enter image description here


As mklement0 commented.
There is no need to enclose the command in & {..}. You can simply put quotes around the command:

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

or

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')"
Sign up to request clarification or add additional context in comments.

1 Comment

@jcjms You're very welcome!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.