WEKF_CustomKey.Remove
支援的版本
✅IoT 企業版 LTSC
✅ IoT 企業✅
版 LTSC
✅ 企業
✅教育版
拿掉自定義按鍵組合,導致鍵盤篩選器停止封鎖移除的按鍵組合。
語法
[Static] uint32 Remove(
[In] string CustomKey
);
參數
CustomKey
[in]要移除的自定義按鍵組合。
傳回值
傳回指出 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);
}
}