答案1
Import-Module -Name International -Force
$WinUserLangList = Get-WinUserLanguageList
Set-WinUserLanguageList -LanguageList $WinUserLangList -Force
Restart-Computer -Confirm -Force # !!! May be important !!! #
上述 PowerShell 脚本应该但我不明白最后一个命令是否Restart-Computer
真的有必要(有时这是完成工作所必需的。
可以使用DISM
实用程序(部署映像服务和管理工具,需要提升) 中的Active keyboard(s)
行DISM.exe /Online /Get-Intl
。例如:
DISM.exe /Online /Get-Intl | findstr /i "Active.keyboard"
Active keyboard(s) : 0809:00000405, 0405:00000405, 0405:00020409, 0408:00010408, 0419:00020419, 041b:0000041b, 041f:0000041f, 041f:00000426, 0425:00000425, 0425:00010409, 0809:00000452
事实上,这些值存储在以下注册表项下:
HKEY_USERS\.DEFAULT\Control Panel\International\User Profile
HKEY_USERS\.DEFAULT\Control Panel\International\User Profile System Backup
我编写了以下脚本来获取人类可读输出而不是黑暗而晦涩 0419:00020419
,,041b:0000041b
…
$regBase = 'Registry::' +
'HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts'
Function Get-Intl {
param( [string]$InputMethodTip )
$auxlang, $auxKeyb = $InputMethodTip -split ':'
$auxLangIn = [System.Globalization.CultureInfo]::
GetCultureInfo( [int]"0x$auxlang" ) # -band 0x3FF )
[psCustomObject]@{
InputMethodTip = $InputMethodTip
Name = $auxLangIn.Name
# Autonym = $WinUserLanguage.Autonym
KbdLayoutName = Get-ItemPropertyValue -Name 'Layout Text' -Path (
Join-Path -Path $regBase -ChildPath $auxKeyb
) -ErrorAction SilentlyContinue
}
}
'--- Get-WinUserLanguageList output:'
ForEach ( $WinUserLanguage in ( Get-WinUserLanguageList ) ) {
$WinUserLanguage.InputMethodTips | ForEach-Object {
Get-Intl -InputMethodTip $_
}
}
'=== HKEY_USERS/DISM.EXE output:'
$regDefa = 'Registry::' +
'HKEY_USERS\.DEFAULT\Control Panel\International\User Profile'
# HKEY_USERS\.DEFAULT\Control Panel\International\User Profile System Backup
Get-ChildItem -Path $regDefa -Force |
Select-Object -ExpandProperty Property |
Where-Object { $_ -match ':' } |
ForEach-Object {
Get-Intl -InputMethodTip $_
}
输出(截断):
D:\PShell\tests\InputMethodTip.ps1
--- Get-WinUserLanguageList output: InputMethodTip Name KbdLayoutName -------------- ---- ------------- 0809:00000452 en-GB United Kingdom Extended 0405:00000405 cs-CZ Czech 0405:00020409 cs-CZ United States-International 0408:00010408 el-GR Greek (220) 0419:00020419 ru-RU Russian - Mnemonic === HKEY_USERS/DISM.EXE output: 0809:00000452 en-GB United Kingdom Extended 0405:00000405 cs-CZ Czech …