Skip to content

Instantly share code, notes, and snippets.

@chall8908
Created April 29, 2017 02:48
Show Gist options
  • Save chall8908/8fd6e6b9ac3765a368c7580b365d4f60 to your computer and use it in GitHub Desktop.
Save chall8908/8fd6e6b9ac3765a368c7580b365d4f60 to your computer and use it in GitHub Desktop.
Small script to swap Caps Lock and Control (with "automatic" privilege escalation)
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
$hexified = "00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00".Split(',') | % { "0x$_"};
$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment