WEKF_CustomKey.Remove
支持的版本
✅IoT 企业 LTSC
✅ IoT 企业
✅版 LTSC
✅ 企业教育版
✅
删除自定义组合键,导致键盘筛选器停止阻止已删除的组合键。
语法
[Static] uint32 Remove(
[In] string CustomKey
);
参数
CustomKey
[in]要删除的自定义组合键。
返回值
返回一个 HRESULT 值,该值指示 WMI 状态 或 WMI 错误。
备注
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);
}
}