16

Steps

Launch PowerShell 7 on Windows 10.

Actual result

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

Expected result

No warning is displayed when PowerShell starts, since I am not using a screen reader.

Workaround

Run the specified command Import-Module PSReadLine. I haven't run this since I first want to understand why the warning is here.

$PSVersionTable output:

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

Additional info

I have Visual Studio 2017, 2019 installed

1
  • 1
    This warning starts appearing on Powershell 5 also once Powershell 7 is installed in the system
    – Nedko
    Aug 16, 2020 at 8:38

2 Answers 2

25

Set the following registry key:

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

to value 0 and reboot.

I discovered this alternative solution via the issue mentioned by @Znatz.

Source

1
  • 1
    If you prefer to update the registry with Powershell instead of regedit: Set-ItemProperty -Path 'HKCU:\Control Panel\Accessibility\Blind Access' -Name On -Value 0
    – johnb
    Apr 7 at 7:58
15

There is a fix for this error.

Powershell issue #11751

Create a .ps1 file, paste the following code and run it with 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)
}
1
  • Thanks! I preferred the manual registry update mentioned in the issue you linked to. I added it as a different answer. May 5, 2020 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.