在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 2017,2019
发布于 2020-05-05 06:35:18
设置以下注册表项:
Windows Registry
Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access\On若要评估0和重新启动,请执行以下操作。
我通过@Znatz提到的问题找到了这个替代解决方案。
发布于 2020-05-05 02:40:22
对此错误有一个修正。
创建一个.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)
}https://serverfault.com/questions/1014754
复制相似问题