Windows PowerShell ISE 不提示输入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8332805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:33:49  来源:igfitidea点击:

Windows PowerShell ISE doesn't promt for input

windowspowershellmercurialcmd

提问by Xorty

I am using console as my tool for managing mercurial repositories. Wtih classic cmdor Console2I type:

我使用控制台作为管理 mercurial 存储库的工具。使用经典的cmdConsole2我输入:

hg in

And console prompts something like:

控制台提示如下:

D:\workspace\someproject>hg in
http authorization required
realm: Bitbucket.org HTTP
user: xorty
password:

And obviously, I type password.

显然,我输入了密码。

But when I type "hg in" in powershell console, it doesn't prompt anything. It just keeps saying this: Running script / selection. Press Ctrl + Break to stop

但是当我在 powershell 控制台中输入“hg in”时,它没有提示任何内容。它只是一直在说: Running script / selection. Press Ctrl + Break to stop

Can I make PowerShell ISE behave like classic console, or this isn't the way PowerShell is meant to work?

我可以让 PowerShell ISE 像经典控制台一样运行,或者这不是 PowerShell 的工作方式?

回答by Joey

The PowerShell ISE indeed does not support console applications that require interactive input. The linked blog entry details options how to deal with that.

PowerShell ISE 确实不支持需要交互式输入的控制台应用程序。链接的博客条目详细说明了如何处理的选项。

Since the PowerShell ISE is not a console, normal console applications cannot do everything they're used to, while of course PowerShell cmdlets can work just fine, since several things are dependent on the PowerShell host application (you get a graphical prompt with Read-Host, for example).

由于 PowerShell ISE 不是控制台,因此普通的控制台应用程序无法执行它们习惯的所有操作,当然,PowerShell cmdlet 可以正常工作,因为有几件事依赖于 PowerShell 主机应用程序(您将获得带有 Read-主机,例如)。

Console2 emulates a normal console by keeping the actual console around in a hidden window and polling it repeatedly for changes and, correspondingly, sending input to that window.

Console2 通过将实际控制台保留在隐藏窗口中并反复轮询更改并相应地将输入发送到该窗口来模拟普通控制台。

回答by manojlds

Powershell ISE ( integrated scripting environment ) is not the standard Powershell console. The ISE, like the name suggests, is a pretty basic GUI based script writing tool and doesn't support interactive console applications ( try just cmdon the ISE console and see the error message)

Powershell ISE(集成脚本环境)不是标准的 Powershell 控制台。ISE,顾名思义,是一个非常基本的基于 GUI 的脚本编写工具,不支持交互式控制台应用程序(仅cmd在 ISE 控制台上尝试并查看错误消息)

Open powershell.exe, and run the command that you want. It will behave pretty much like cmd. Or alternatively, press CTRL+SHIFT+Pin the ISE and run the command there.

打开 powershell.exe,然后运行所需的命令。它的行为与 cmd 非常相似。或者,在 ISE 中按CTRL+ SHIFT+P并在那里运行命令。