简体   繁体   English

从命令行运行时,Powershell host.ui.prompt不会弹出对话框

[英]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 )运行它时,不会弹出任何对话框:而是显示命令行提示,如下所示:

DOS框文字提示

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.

相关问题 用UI对话框替换提示 - replace prompt with UI dialog wxWidgets对话框没有获得最大化框 - wxWidgets dialog doesn't get a maximize box 使用PyQt创建的自定义窗口小部件不会在启动时加载,但会在从命令行启动程序时加载 - A custom widget created with PyQt doesn't load on boot but loads when program is started from command line 键盘锁锁定时,弹出对话框或来自服务的活动在Android中在后台运行? - Pop-up dialog or Activity from Service running in Background in Android when keyguard is locked? 程序启动时如何弹出对话框窗口? - How to make Dialog Window pop up when the program starts? 屏幕捕获命令行工具可从命令行使用,但从UI内部启动时 - Screen capture command line tool works from command line but when started from inside of UI 为什么我的jQuery UI对话框在嵌套div时不显示? - Why won't my jQuery UI dialog show up when it's div is nested? 与第三方命令行程序的提示符与Windows Command提示符的交互方式如何? - How is interacting with a prompt of a third party command line program different from a Windows Command prompt? Android输入对话框的Onclick无效 - Android Input Dialog Box's Onclick doesn't work 无法正确定义关闭主程序框架和弹出对话框的处理程序方法 - Can't properly define handler method to close main program frame and dialog pop-up
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM