我寫了一個需要輸入框的批處理腳本,首先這是代碼行:
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
uj5u.com熱心網友回復:
你可以這樣做:
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')}"

正如mklement0評論的那樣。
無需將命令括在& {..}. 您可以簡單地在命令周圍加上引號:
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')"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/368900.html
