[英]Powershell host.ui.prompt doesn't pop up a dialog box when run from the command line
This is a follow-up to my earlier question 这是我之前的问题的后续行动
I have written a script which uses $host.ui.prompt
. 我编写了一个使用$host.ui.prompt
的脚本。
The script runs fine when I run it from my editor ( PowerGUI ), and the dialog box pops up nicely to prompt the user for input, like this: 当我从我的编辑器( PowerGUI )运行脚本时,脚本运行正常,并且对话框弹出很好,提示用户输入,如下所示:
. 。
However, when I run it from a command line ( powershell .\\script.ps1
), no dialog box pops up: instead, command line prompts appear, like this: 但是,当我从命令行( powershell .\\script.ps1
)运行它时,不会弹出任何对话框:而是显示命令行提示,如下所示:
I expected that the script would pop up the nice dialog box for me as before. 我希望脚本会像以前一样为我弹出漂亮的对话框。
What am I missing? 我错过了什么?
The $host.ui.prompt
like the name says, is specific to the host implementation. 名称所示的$host.ui.prompt
特定于主机实现。 PowerGui have impemented a custom host / prompt which is GUI based. PowerGui已经强制要求基于GUI的自定义主机/提示。 The default prompt on the console is the text one that you see. 控制台上的默认提示是您看到的文本。
Maybe you want to look here: http://www.windowsitpro.com/blog/powershell-with-a-purpose-blog-36/scripting-languages/getting-input-and-inputboxes-in-powershell-137449 也许你想看看这里: http : //www.windowsitpro.com/blog/powershell-with-a-purpose-blog-36/scripting-languages/getting-input-and-inputboxes-in-powershell-137449
and here: 和这里:
http://technet.microsoft.com/en-us/library/ff730941.aspx http://technet.microsoft.com/en-us/library/ff730941.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.