WEKF_CustomKey.Remove

カスタム キーの組み合わせを削除し、削除されたキーの組み合わせをキーボード フィルターでブロックしないようにします。

構文

[Static] uint32 Remove(
    [In] string CustomKey
);

パラメーター

CustomKey
[入力]削除するカスタム キーの組み合わせ。

戻り値

WMI の状態または WMI エラーを示す HRESULT 値を返します。

注釈

WEKF_CustomKey.Remove は、既存の WEKF_CustomKey オブジェクトを削除します。 このオブジェクトが存在しない場合、WEKF_CustomKey.Remove は、値 0x8007007B のエラーを返します。

このメソッドは静的なので、オブジェクト インスタンスで呼び出すことはできません。代わりに、クラス レベルで呼び出す必要があります。

次のコードは、カスタム キーをキーボード フィルターから削除する方法を示しています。これにより、キーボード フィルターに Windows Management Instrumentation (WMI) プロバイダーを使用してもカスタム キーはブロックされなくなります。

$COMPUTER = "localhost"
$NAMESPACE = "root\standardcimv2\embedded"

# Create a handle to the class instance so we can call the static methods
$classCustomKey = [wmiclass]"\\$COMPUTER\${NAMESPACE}:WEKF_CustomKey"

# Create a function to remove a key combination
function Remove-Custom-Key($KeyId) {

# Call the static Remove() method on the class reference
    $retval = $classCustomKey.Remove($KeyId)

# Check the return value for status
    if ($retval.ReturnValue -eq 0) {

# Custom key combination removed successfully
        "Removed ${KeyID}."
    } elseif ($retval.ReturnValue -eq 2147942523) {

# No object exists with the specified custom key
        "Failed to remove ${KeyID}. No object found."
    } else {

# Unknown error, report error code in hexadecimal
        "Failed to remove ${KeyID}. Unknown Error: " + "{0:x0}" -f $retval.ReturnValue
    }
}


# Example of removing a custom key so that Keyboard Filter stops blocking it
Remove-Custom-Key "Ctrl+Alt+w"

# Example of removing all custom keys that have the Enabled property set to false
$objDisabledCustomKeys = Get-WmiObject -Namespace $NAMESPACE -Class WEKF_CustomKey;

foreach ($objCustomKey in $objDisabledCustomKeys) {
    if (!$objCustomKey.Enabled) {
        Remove-Custom-Key($objCustomKey.Id);
    }
}

要件

Windows エディション サポートされています
Windows ホーム いいえ
Windows Pro いいえ
Windows Enterprise はい
Windows Education はい
Windows IoT Enterprise はい