AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1014754
Accepted
Bernard Vander Beken
Bernard Vander Beken
Asked: 2020-04-30 01:03:42 +0800 CST2020-04-30 01:03:42 +0800 CST 2020-04-30 01:03:42 +0800 CST

警告原因:PowerShell 检测到您可能正在使用屏幕阅读器并出于兼容性目的禁用了 PSReadLine

  • 772

脚步

在 Windows 10 上启动 PowerShell 7。

实际结果

PowerShell 7.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.

预期结果

PowerShell 启动时不显示警告,因为我没有使用屏幕阅读器。

解决方法

运行指定的命令Import-Module PSReadLine。自从我第一次想了解为什么出现警告以来,我还没有运行它。

$PSVersionTable输出:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

附加信息

我安装了 Visual Studio 2017、2019

powershell powershell-v7
  • 2 2 个回答
  • 17750 Views

2 个回答

  • Voted
  1. Best Answer
    Bernard Vander Beken
    2020-05-05T22:35:18+08:002020-05-05T22:35:18+08:00

    设置以下注册表项:

    Windows Registry 
    Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access\On
    

    重视0并重新启动。

    我通过@Znatz 提到的问题发现了这个替代解决方案。

    资源

    • 22
  2. Znatz
    2020-05-05T18:40:22+08:002020-05-05T18:40:22+08:00

    有针对此错误的修复程序。

    Powershell 问题 #11751

    创建一个 .ps1 文件,粘贴以下代码并使用 powershell 运行它。

    Add-Type -TypeDefinition '
    using System;
    using System.ComponentModel;
    using System.Runtime.InteropServices;
    
    public static class ScreenReaderFixUtil
    {
        public static bool IsScreenReaderActive()
        {
            var ptr = IntPtr.Zero;
            try
            {
                ptr = Marshal.AllocHGlobal(sizeof(int));
                int hr = Interop.SystemParametersInfo(
                    Interop.SPI_GETSCREENREADER,
                    sizeof(int),
                    ptr,
                    0);
    
                if (hr == 0)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }
    
                return Marshal.ReadInt32(ptr) != 0;
            }
            finally
            {
                if (ptr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(ptr);
                }
            }
        }
    
        public static void SetScreenReaderActiveStatus(bool isActive)
        {
            int hr = Interop.SystemParametersInfo(
                Interop.SPI_SETSCREENREADER,
                isActive ? 1u : 0u,
                IntPtr.Zero,
                Interop.SPIF_SENDCHANGE);
    
            if (hr == 0)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
    
        private static class Interop
        {
            public const int SPIF_SENDCHANGE = 0x0002;
    
            public const int SPI_GETSCREENREADER = 0x0046;
    
            public const int SPI_SETSCREENREADER = 0x0047;
    
            [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
            public static extern int SystemParametersInfo(
                uint uiAction,
                uint uiParam,
                IntPtr pvParam,
                uint fWinIni);
        }
    }'
    
    if ([ScreenReaderFixUtil]::IsScreenReaderActive()) {
        [ScreenReaderFixUtil]::SetScreenReaderActiveStatus($false)
    }
    
    • 12

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve