Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re enable Import Module Psreadline warning

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.

like image 304
Wasg Coco Avatar asked Sep 10 '25 20:09

Wasg Coco


2 Answers

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 PIC (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 to re-enable PSReadLine for a rich command-line editing experience, 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 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)
like image 150
mklement0 Avatar answered Sep 13 '25 08:09

mklement0


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!

like image 27
Nicolas Jit Avatar answered Sep 13 '25 10:09

Nicolas Jit