powershell - 按任意键继续

标签 powershell

根据 Microsoft 的 documentation , read-host让用户输入一些内容,然后按 Enter 继续。如果您想要“按任意键继续”,则不完全是正确的行为。 (等等...Any 键在哪里?!)

有办法实现这一点吗?类似 read-char

我尝试搜索“单字符输入”和“powershell 输入”,看看是否能找到所有获取输入方式的列表,但运气不佳。以及几个看起来很有希望使用的 Stack Overflow 问题 read-host这实际上不适用于“按任意键...”功能。

最佳答案

这是我使用的。

Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');

关于powershell - 按任意键继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20886243/

相关文章:

regex - PowerShell Regex替换产生空输出

PowerShell 功能和性能

.net - 形式成为焦点

Powershell - 如何读取 Ansi CSV 文件

entity-framework - 从云服务项目的 powershell 运行 migrate.exe?

powershell - 将 Powershell 核心设置为 windows/linux 上的默认 GNU Make shell

powershell - 使用Docker安装Powershell devbox Magento

powershell - Powershell:与x86 powershell/ise一起运行的脚本

powershell - Windows10/Powershell : How to use -include parameter when using Get-Childitem?

powershell - 回到目录