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.
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:
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 turn the mode off ad hoc so that future PowerShell sessions in the same OS user session no longer see the warning:
The following, gratefully adapted from this GitHub comment, is a PowerShell command that does this via Add-Type
and ad hoc-compiled C# code (which is necessary to perform P/Invoke calls):
# Run in PowerShell
(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)