Skip to content

Instantly share code, notes, and snippets.

@bazzilic
Last active June 3, 2025 18:23
Show Gist options
  • Select an option

  • Save bazzilic/6d077e319ff36cbe9f4182c07f77821f to your computer and use it in GitHub Desktop.

Select an option

Save bazzilic/6d077e319ff36cbe9f4182c07f77821f to your computer and use it in GitHub Desktop.

How To Use This Script

First, you need to enable script execution in your PowerShell: https://superuser.com/a/106363

Second, make a folder where you will store this script. For example, it could be ~/scripts, where ~ is a system substitute for your home folder (C:\Users\<your login>). Create the folder and download the FixAutoAddedKBLayout.ps1 script in it. Running this script (right-click and run) should fix the keyboard layouts.

This won't fix the layouts forever, the extra layout will come back at some point. So what I did was setup a schedule to run this script every once in a while. This is done using the RegisterCronJob.ps1 script. Put it in the same folder and run it. That should register a schedule to run FixAutoAddedKBLayout.ps1 every time the computer is idle for 3 minutes. You can edit the condition to start the script using information on that page.

param (
[String]$LanguageToFix = 'en-SG'
)
$lng = Get-WinUserLanguageList
$lng.Add($LanguageToFix)
Set-WinUserLanguageList -Force $lng
$lng.Remove( ( $lng | Where-Object LanguageTag -like $LanguageToFix ) ) 2>&1 | Out-Null
Set-WinUserLanguageList -Force $lng
schtasks /create /sc ONIDLE /i 3 /tn 'Fix keyboard layout issue' /tr "$(pwd)\FixAutoAddedKBLayout.ps1"
@Rexeh
Copy link

Rexeh commented Nov 13, 2023

Thanks, works great. Very annoying windows bug.

@laymeh
Copy link

laymeh commented Feb 15, 2024

Hi, I tried running the script and my target lang is en-US, but it gives me an "Cannot find an overload for "Remove" and the argument count "1"
I have 2 main languages which is Ukrainian and English UK, so should I change something in the code or something?
Will be really grateful for any help since I am not that good with codes and can't really understand why it's not running the way it should :)
Screenshot 2024-02-12 190102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment