Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
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:

dialog box appears as expected.

However, when I run it from a command line (powershell .\script.ps1), no dialog box pops up: instead, command line prompts appear, like this:

DOS box text prompts

I expected that the script would pop up the nice dialog box for me as before.

What am I missing?

like image 890
AJ. Avatar asked Sep 15 '25 20:09

AJ.


1 Answers

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

like image 91
manojlds Avatar answered Sep 19 '25 22:09

manojlds