Quitar configuraciones de combinación de teclas

Ediciones
✅ compatibles IoT Enterprise LTSC
✅ IoT Enterprise
✅ LTSC✅
Enterprise
✅ Educación

El siguiente script de muestra de Windows PowerShell usa los proveedores de Instrumental de administración de Windows (WMI) para filtro de teclado para crear dos funciones que quitan las configuraciones de reglas de bloqueo personalizadas. Al quitar una regla, se elimina esa configuración, pero otra regla activa aún podría bloquear la misma entrada física.

La primera función, Remove-Custom-Key, quita las reglas de bloqueo de las claves personalizadas.

La segunda función, Remove-Scancode, elimina las reglas de bloqueo del código de análisis.

No se pueden quitar las reglas de bloqueo de clave predefinida, pero se pueden desactivar si se establece su Enabled propiedad en 0.

Remove-rules.ps1

#
# Copyright (C) Microsoft. All rights reserved.
#

<#
.Synopsis
    This script uses the built-in WMI providers to remove Keyboard Filter blocking rules. WEKF_PredefinedKey rules can't be removed.
.Parameter ComputerName
    Optional parameter to specify the remote computer that this script should
    manage.  If not specified, the script will execute all WMI operations
    locally.
#>

param(
    [string] $ComputerName
)

$CommonParams = @{"namespace"="root\standardcimv2\embedded"}
$CommonParams += $PSBoundParameters

function Remove-Custom-Key($Id) {
    <#
    .Synopsis
        Remove a WEKF_CustomKey blocking rule.
    .Description
        Enumerate all WEKF_CustomKey instances. When an instance has an Id that
        matches $Id, delete it.
    .Example
        Remove-Custom-Key "Ctrl+V"

        Removes the WEKF_CustomKey blocking rule for Ctrl+V.
#>

    $customInstance = Get-WMIObject -class WEKF_CustomKey @CommonParams |
        where {$_.Id -eq $Id}

    if ($customInstance) {
        $customInstance.Delete();
        "Removed custom-key blocking rule for $Id.";
    } else {
        "Custom-key blocking rule for $Id does not exist.";
    }
}

function Remove-Scancode($Modifiers, [int]$Code) {
    <#
    .Synopsis
        Remove a WEKF_Scancode blocking rule.
    .Description
        Enumerate all WEKF_Scancode instances. When an instance has matching
        Modifiers and Scancode values, delete it.
    .Example
        Remove-Scancode "Ctrl" 37

        Removes the WEKF_Scancode blocking rule with Modifiers="Ctrl" and
        Scancode=37.
#>

    $scancodeInstance = Get-WMIObject -class WEKF_Scancode @CommonParams |
        where {($_.Modifiers -eq $Modifiers) -and ($_.Scancode -eq $Code)}

    if ($scancodeInstance) {
        $scancodeInstance.Delete();
        "Removed scan-code blocking rule for $Modifiers+$Code";
    } else {
        "Scan-code blocking rule for $Modifiers+$Code does not exist.";
    }
}

# Some example uses of the functions defined above.
Remove-Custom-Key "Ctrl+V"
Remove-Custom-Key "Numpad0"
Remove-Custom-Key "Shift+Numpad1"
Remove-Custom-Key "Shift+5"
Remove-Scancode "Ctrl" 37

Ejemplos de script de Windows PowerShell para el filtro de teclado

Referencia de proveedor WMI de filtro de teclado

Filtro de teclado