从命令行运行时,Powershell host.ui.prompt 不会弹出对话框
这是我的之前的问题
我编写了一个使用 $host.ui.prompt
的脚本。
当我从编辑器(PowerGUI)运行该脚本时,该脚本运行良好,并且弹出对话框很好地提示用户对于输入,如下所示:
。
但是,当我从命令行(powershell .\script.ps1
)运行它时,没有弹出对话框:而是出现命令行提示,如下所示:
我希望脚本会像以前一样为我弹出漂亮的对话框。
我错过了什么?
This is a follow-up to my earlier question
I have written a script which uses $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:
.
However, when I run it from a command line (powershell .\script.ps1
), no dialog box pops up: instead, command line prompts appear, like this:
I expected that the script would pop up the nice dialog box for me as before.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$host.ui.prompt
正如其名称所示,特定于主机实现。 PowerGui 实现了基于 GUI 的自定义主机/提示符。控制台上的默认提示是您看到的文本提示。也许你想看这里:http:// www.windowsitpro.com/blog/powershell-with-a- Purpose-blog-36/scripting-languages/getting-input-and-inputboxes-in-powershell-137449
在这里:
http://technet.microsoft.com/en-us/library/ff730941.aspx
The
$host.ui.prompt
like the name says, is specific to the host implementation. PowerGui have impemented a custom host / prompt which is GUI based. 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
and here:
http://technet.microsoft.com/en-us/library/ff730941.aspx