17

This warning keeps popping in the terminal of Visual Code app

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

Even if I change the value to 0 via regedit, the warning still shows.

mklement0
  • 382,024
  • 64
  • 607
  • 775
Wasg Coco
  • 197
  • 1
  • 1
  • 9

2 Answers2

25

The implications of your symptom are:

  • Windows is in screen-reader mode (a Windows accessibility feature for the visually impaired) at the time your PowerShell session starts.

  • You're using a regular PowerShell session, either in a console window / in Windows Terminal or in Visual Studio Code's integrated terminal.

    • By contrast, if you use Visual Studio Code with the PowerShell extension, which enables a much richer PowerShell code-authoring experience, the problem doesn't occur, because the sessions provided by the extension in the so-called PowerShell Integrated Console do not perform this check (as of version 2021.2.2), and therefore do load PSReadLine (the module providing a rich command-line editing experience) and do not emit a warning. It is unclear if this unconditional override is by design or an oversight.

    • While you could follow the advice in the error message and add
      Import-Module PSReadLine to your $PROFILE file and doing so will re-enable PSReadLine for a rich command-line editing experience, but you'll still see the warning on startup, because it is emitted by PowerShell before the $PROFILE file is loaded. That said, if screen-reader mode is enabled by design on your system, this is the right solution.


If this mode is (accidentally) turned on persistently, via the registry, you can turn it off as follows:

Set-ItemProperty 'registry::HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access' On 0

Note:

  • This change requires a logoff or reboot to take effect.
  • To query the persistent mode, use:
Get-ItemPropertyValue 'registry::HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access' On

If this mode has accidentally been turned on in-OS-session, by an application that is either ill-behaved in that it doesn't turn the mode back off again or has crashed before being able to do so, you can ad-hoc compile C# code to turn the mode off (gratefully adapted from this GitHub comment) so that future PowerShell sessions in the same OS user session no longer see the warning:

(Add-Type -PassThru -Name ScreenReaderUtil -Namespace WinApiHelper -MemberDefinition @'
  const int SPIF_SENDCHANGE = 0x0002;
  const int SPI_SETSCREENREADER = 0x0047;

  [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)]
  private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);

  public static void EnableScreenReader(bool enable)
  {
    var ok = SystemParametersInfo(SPI_SETSCREENREADER, enable ? 1u : 0u, IntPtr.Zero, SPIF_SENDCHANGE);
    if (!ok)
    {
      throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
    }
  }
'@)::EnableScreenReader($false)
mklement0
  • 382,024
  • 64
  • 607
  • 775
  • 2
    The registry trick worked for me. – Miro J. Jan 26 '22 at 15:02
  • 1
    *if its answered very well/and its about powershell/thats mklement0* (sung to the tune of 'Thats Amore') – codeulike Nov 17 '22 at 23:26
  • I just installed the extention, but i dont see any effect, still getting this message. Also Im wondering this message started to occure when I started to use screen reader, but I didnt change anything in the settings of windows, was it changed by sr? – daza May 27 '23 at 10:53
  • @daza, I have no explanation for your symptom, and on my Windows 11 machine the registry setting doesn't seem to change anymore when you turn on screen reader, and I don't even get the warning anymore. – mklement0 May 27 '23 at 13:11
  • @daza, when I manually set the registry setting to `1` in Windows 11 - which does _not_ correspond to turning on the screen reader - I still see the behavior described in this answer. – mklement0 May 27 '23 at 13:51
1

You can also try this(just woked for me)

Step 1: Open "RUN" (WIN + R)

Step 2: Type "regedit"

Step 3: On the left side, there is a folder named "HKEY_CURRENT_USER"; click on it.

Step 4: Click the sub-folder named "Control Panel" and then click the sub-folder named "Blind access" or follow this path Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access

Step 5: Right Click on the option "On", chose the option "Modify" and then set the value 0.

Now Restart your computer, and PROBLEM SOLVED!

Zujaj Misbah Khan
  • 655
  • 2
  • 11
  • 31
Nicolas Jit
  • 66
  • 1
  • 5