針對特定使用者的 Powershell 鍵盤過濾器

針對特定使用者的 Powershell 鍵盤過濾器

來自微軟的此頁面:https://docs.microsoft.com/en-us/windows-hardware/customize/enterprise/keyboardfilter-add-blocked-key-combinations解釋如何建立將停用特定組合鍵的 powershell 腳本。

這是相關的程式碼片段...

function Enable-Custom-Key($Id) {
    <#
    .Synopsis
        Toggle on a Custom Key keyboard filter Rule
    .Description
        Use Get-WMIObject to enumerate all WEKF_CustomKey instances,
        filter against key value "Id", and set that instance's "Enabled"
        property to 1/true.

        In the case that the Custom instance does not exist, add a new
        instance of WEKF_CustomKey using Set-WMIInstance.
    .Example
        Enable-Custom-Key "Ctrl+V"
        Enable filtering of the Ctrl + V sequence.
#>

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

    if ($custom) {
# Rule exists.  Just enable it.
        $custom.Enabled = 1;
        $custom.Put() | Out-Null;
        "Enabled Custom Filter $Id.";

    } else {
        Set-WMIInstance `
            -class WEKF_CustomKey `
            -argument @{Id="$Id"} `
            @CommonParams | Out-Null
        "Added Custom Filter $Id.";
    }
}


Enable-Custom-Key "Windows+U"
# etc.

但是,有沒有一種方法可以停用組合鍵,但僅限於特定使用者? (即我想要同一台電腦上的另一個「管理員」使用者可以繼續使用組合鍵)

我想也許以該用戶身份登入並運行腳本就可以做到這一點,但首先,它似乎只有在我以管理員身份運行Powershell 時才有效,然後當我這樣做時,我會重新登出並以另一個使用者身分重新登錄, “管理員”使用者和組合鍵也在這裡被封鎖。

這就是 Windows 10 物聯網。

(順便說一句,我願意接受根本不使用 Powershell 的答案。我之前被告知要使用群組原則編輯器,但我找不到鍵盤過濾器部分)

答案1

嘗試停用KeyboardFilterForAdministrators

相關內容