How to change keyboard layout via command line cmd.exe on Windows XP/7?

Solution 1:

yes.

Configuring Regional and Language Options International Settings with command line automation

Windows Vista Command Line Configuration of International Settings

command line example:

control intl.cpl,, /f:"%CD%\AddKeyboardLanguage.xml"

AddKeyboardLanguage.xml example:

<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend"> 
<gs:UserList>
<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/></gs:UserList> 
<gs:InputPreferences> 

<!--ch-Google--><gs:InputLanguageID Action="add" ID="0804:E0200804"/>

</gs:InputPreferences>
</gs:GlobalizationServices>

RemoveKeyboardLanguage.xml example:

<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend"> 
<gs:UserList>
<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/></gs:UserList> 
<gs:InputPreferences> 

<!--ch-Google--><gs:InputLanguageID Action="remove" ID="0804:E0200804"/>

</gs:InputPreferences>
</gs:GlobalizationServices>

Solution 2:

Windows 8 brings a new International PowerShell module. Unfortunately it doesn't seem like this can be backported or has any Windows 7 alternative


Configure international settings by using PowerShell cmdlets

In Windows 8 you can use the International Settings PowerShell cmdlets to change the language on a running Windows installation. The benefit of using PowerShell cmdlets is that you can incorporate them into a script to facilitate deployment and configuration of Windows. Source: http://technet.microsoft.com/en-us/library/hh825705.aspx

  1. Open a Windows PowerShell prompt.
  2. Import the international settings module by running the following command:

    ipmo international

  3. Display the locale information on the computer by running the following command:

    Get-WinSystemLocale

  4. Set the locale for the region and language that you want. For example, the following command sets the system locale to Japanese (Japan):

    Set-WinSystemLocale ja-JP

Solution 3:

"Windows 8 brings a new International PowerShell module. Unfortunately it doesn't seem like this can be backported or has any Windows 7 alternative"

You could try this (example).. this enables only the selected keyboard layouts and clears the others

Install-Module -name timezone -force
#Sets the systems timezone on "Western Europe Standard time" 
$langlist = New-WinUserLanguageList en-US

#Clears the other input methods from the displayed language
$langlist[0].InputMethodTips.Clear()

#Sets and adds the swiss-German keyboard
$langlist[0].InputMethodTips.add('0409:00000807')

#Sets and adds the swiss-french keyboard
$langlist[0].InputMethodTips.add('0409:0000100C')

#Apply the changes made on the system (and force to avoid the prompt  message)
Set-WinUserLanguageList $langlist -Force