WEKF_PredefinedKeyWEKF_PredefinedKey

此类阻止或取消阻止预定义的组合键,如 Ctrl + Alt + Delete。This class blocks or unblocks predefined key combinations, such as Ctrl+Alt+Delete.

语法Syntax

class WEKF_PredefinedKey {
    [Static] uint32 Enable (
        [In] string PredefinedKey
    );
    [Static] uint32 Disable (
        [In] string PredefinedKey
    );

    [Key] string Id;
    [Read, Write] boolean Enabled;
};

MembersMembers

下表列出了属于此类的任何构造函数、方法、字段和属性。The following tables list any constructors, methods, fields, and properties that belong to this class.

方法Methods

方法Methods 说明Description
WEKF_PredefinedKey.EnableWEKF_PredefinedKey.Enable 阻止指定的预定义键。Blocks the specified predefined key.
WEKF_PredefinedKey.DisableWEKF_PredefinedKey.Disable 取消阻止指定的预定义密钥。Unblocks the specified predefined key.

属性Properties

属性Property 数据类型Data type 限定符Qualifiers 说明Description
识别Id stringstring 按键[key] 预定义组合键的名称。The name of the predefined key combination.
EnabledEnabled 布尔Boolean [读取、写入][read, write] 指示密钥是否被阻止或解除阻止。Indicates whether the key is blocked or unblocked. 若要指示密钥被阻止,请指定trueTo indicate that the key is blocked, specify true. 若要指示该项未被阻止,请指定falseTo indicate that the key is not blocked, specify false.

备注Remarks

所有帐户都具有对WEKF_PRedefinedKey类的读取访问权限,但只有管理员帐户可以修改类。All accounts have read access to the WEKF_PRedefinedKey class, but only administrator accounts can modify the class.

有关键盘筛选器的预定义组合键的列表,请参阅预定义的组合键For a list of predefined key combinations for Keyboard Filter, see Predefined key combinations.

示例Example

下面的 Windows PowerShell 脚本示例在键盘筛选器服务运行时阻止 Ctrl + Alt + Delete 和 Ctrl + Esc 组合键。The following sample Windows PowerShell script blocks the Ctrl+Alt+Delete and the Ctrl+Esc key combinations when the Keyboard Filter service is running.

<#
.Synopsis
    This script shows how to use the built in WMI providers to enable and add 
    Keyboard Filter rules through Windows PowerShell on the local computer.
.Parameter ComputerName
    Optional parameter to specify a remote machine 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 Enable-Predefined-Key($Id) {
    <#
    .Synposis
        Toggle on a Predefined Key Keyboard Filter Rule
    .Description
        Use Get-WMIObject to enumerate all WEKF_PredefinedKey instances,
        filter against key value "Id", and set that instance's "Enabled"
        property to 1/true.
    .Example
        Enable-Predefined-Key "Ctrl+Alt+Delete"

        Enable CAD filtering
#>

    $predefined = Get-WMIObject -class WEKF_PredefinedKey @CommonParams |
        where {
            $_.Id -eq "$Id"
        };

    if ($predefined) {
        $predefined.Enabled = 1;
        $predefined.Put() | Out-Null;
        Write-Host Enabled $Id
    } else {
        Write-Error $Id is not a valid predefined key
    }
}

# Some example uses of the function defined above.

Enable-Predefined-Key "Ctrl+Alt+Delete"
Enable-Predefined-Key "Ctrl+Esc"

要求Requirements

Windows 版本Windows Edition 支持Supported
Windows 10 家庭版Windows 10 Home No
Windows 10 专业版Windows 10 Pro No
Windows 10 企业版Windows 10 Enterprise Yes
Windows 10 教育版Windows 10 Education Yes

键盘筛选器 WMI 提供程序参考Keyboard Filter WMI provider reference

键盘筛选器Keyboard Filter