Category filter
Script to turn off keyboard shortcuts on Windows
Keyboard shortcuts are a convenient way to perform various actions quickly on devices. However, there may be situations where you want to turn off specific keyboard shortcuts based on your needs. In this document, we will explore scripts that allow you to disable or enable keyboard shortcuts across Windows devices and the Microsoft Edge app installed.
Whether you want to temporarily disable certain shortcuts or enable them, the scripts provide a flexible solution. Use Hexnode’s Execute Custom Script feature to remotely deploy these scripts to multiple devices in no time.
PowerShell script to manage keyboard shortcuts on Windows
Disable keyboard shortcuts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
try { $status = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS Function RestrictShortcut($sid) { $policyPath = "HKU:\${sid}\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" # Check if the "Explorer" key exists if (!(Test-Path $policyPath)) { # Create the "Explorer" key New-Item -Path $policyPath -Force | Out-Null } New-ItemProperty -Path $policyPath -Name "NoWinKeys" -Value 1 -PropertyType DWORD -Force | Out-Null } $userDetails=Get-wmiobject win32_useraccount | where-object{$_.status -eq 'ok'} $loggedInUserCount = 0 foreach($user in $userDetails) { $sid=$user.SID $username = $user.Name if(Test-Path "HKU:\${sid}") { Write-Host $username,"is signed-in to the device." Write-Host "Restricting Windows Shortcut for :",$username RestrictShortcut($sid) $loggedInUserCount++ } } if($loggedInUserCount -eq 0) { Write-Host "Policy hasn't applied to any user, this policy can only be applied when the user is logged in to the device" } else { Write-Host "Restart the device to review the changes." } } catch { Write-Host "Error occured while running script -> ",$_.Exception.Message } |
The following keyboard shortcuts are disabled on Windows after executing the above script.
Shortcut key | Function |
---|---|
Windows key + A | Open Quick Settings |
Windows key + Ctrl + F | Search for PCs (if you’re on a network) |
Windows key + E | Open File Explorer |
Windows key + H | Launch voice typing |
Windows key + Pause/Break | Open system information |
Windows key + R | Open the Run dialog box |
Windows key + S | Open search |
Windows key + Shift + S | Capture a screenshot of part of your screen |
Windows key + T | Cycle through apps on the taskbar |
Windows key + V | Open the clipboard history |
Windows key + X | Open the Quick Link menu |
Windows key + Alt + R | Record video of the active game window (using Xbox Game Bar) |
Windows key + Shift + V | Set focus to a notification |
Windows key + number | Open the desktop and launch the app pinned to the taskbar in the specified position indicated by ‘number’. If the app is already running, switch to that app. |
Windows key + Shift + number | Open the desktop and initiate a new instance of the app pinned to the taskbar at the position indicated by ‘number’. |
Enable keyboard shortcuts
Use the below script to enable all keyboard shortcuts on your devices.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
try { $status = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS Function RestrictShortcut($sid) { $policyPath = "HKU:\${sid}\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\" $keyname = "Explorer" if(Test-Path "$policyPath\$keyName") { Remove-Item -Path "$policyPath\$keyName" -Recurse -Force } } $userDetails=Get-wmiobject win32_useraccount | where-object{$_.status -eq 'ok'} $loggedInUserCount = 0 foreach($user in $userDetails) { $sid=$user.SID $username = $user.Name if(Test-Path "HKU:\${sid}") { Write-Host $username,"is signed-in to the device." Write-Host "Enabling Windows Shortcut for :",$username RestrictShortcut($sid) $loggedInUserCount++ } } if($loggedInUserCount -eq 0) { Write-Host "Policy hasn't applied to any user, this policy can only be applied when the user is logged in to the device" } else { Write-Host "Restart the device to review the changes." } } catch { Write-Host "Error occured while running script -> ",$_.Exception.Message } |
PowerShell script to manage keyboard shortcuts on the Edge browser
Disable keyboard shortcuts on Microsoft Edge
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
try { $status = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS Function RestrictShortcut($sid) { $policyPath = "HKU:\${sid}\SOFTWARE\Policies\Microsoft\Edge" $valueName = "ConfigureKeyboardShortcuts" $valueData = '{"disabled": ["open_file", "save_page", "new_inprivate_window", "duplicate_tab", "dev_tools", "web_capture", "collections","profile", "print", "focus_search", "home", "settings_and_more_menu"]}' # Check if the "Edge" key exists if (!(Test-Path $policyPath)) { # Create the "Edge" key New-Item -Path $policyPath -Force | Out-Null } New-ItemProperty -Path $policyPath -Name $valueName -Value $valueData -PropertyType String -Force | Out-Null } $userDetails=Get-wmiobject win32_useraccount | where-object{$_.status -eq 'ok'} $loggedInUserCount = 0 foreach($user in $userDetails) { $sid=$user.SID $username = $user.Name if(Test-Path "HKU:\${sid}") { Write-Host $username,"is signed-in to the device." Write-Host "Restricting Edge Shortcut for :",$username RestrictShortcut($sid) $loggedInUserCount++ } } if($loggedInUserCount -eq 0) { Write-Host "Policy hasn't applied to any user, this policy can only be applied when the user is logged in to the device" } else { Write-Host "Restart the Edge to review the changes." } } catch { Write-Host "Error occured while running script -> ",$_.Exception.Message } |
The keyboard shortcuts given in the table are disabled on Microsoft Edge after executing the above script.
Shortcut key | Function |
---|---|
CTRL + E or CTRL + K | Open search query in the address bar |
CTRL + O | Open a file from your computer in Edge |
CTRL + P | Print the current web page |
CTRL + S | Save the current web page |
CTRL + SHIFT + I | Open Developer Tools |
CTRL + SHIFT + K | Duplicate the current tab |
CTRL + SHIFT + M | Sign in as a different user or browse as a Guest |
CTRL + SHIFT + N | Open a new InPrivate window |
CTRL + SHIFT + S | Save the current webpage as a screenshot |
CTRL + SHIFT + Y | Open Collections |
ALT + HOME | Open your homepage in the current tab |
ALT + E | Open the Edge browser menu |
Enable keyboard shortcuts on Microsoft Edge
The below script enables all keyboard shortcuts on the Microsoft Edge browser.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
try { $status = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS Function RestrictShortcut($sid) { $policyPath = "HKU:\${sid}\SOFTWARE\Policies\Microsoft" $keyname = "Edge" if(Test-Path "$policyPath\$keyName") { Remove-Item -Path "$policyPath\$keyName" -Recurse -Force } } $userDetails=Get-wmiobject win32_useraccount | where-object{$_.status -eq 'ok'} $loggedInUserCount = 0 foreach($user in $userDetails) { $sid=$user.SID $username = $user.Name if(Test-Path "HKU:\${sid}") { Write-Host $username,"is signed-in to the device." Write-Host "Enabling Edge Shortcut for :",$username RestrictShortcut($sid) $loggedInUserCount++ } } if($loggedInUserCount -eq 0) { Write-Host "Policy hasn't applied to any user, this policy can only be applied when the user is logged in to the device" } else { Write-Host "Restart the Edge to review the changes." } } catch { Write-Host "Error occured while running script -> ",$_.Exception.Message } |