无需用户交互即可通过 PowerShell 更改 Windows 10 默认系统语言

无需用户交互即可通过 PowerShell 更改 Windows 10 默认系统语言

我有一个由云计算服务提供的预配置的 Windows 10 VM。

此服务提供的所有 Win10 映像均将英语(美国)设置为默认系统语言。我无法控制这一点。

我想要做的是编写一个脚本,将系统区域设置(包括显示语言、时区、文化信息等)更改为不同的区域设置,例如德语(德国)。

要求如下

  • 切换必须完全自动化,因此不需要手动用户交互(即无需手动下载任何内容,或在系统设置对话框中更改任何内容)。
  • 更改必须是永久性的(即,虚拟机重启后仍然有效)。

我怎么做?

答案1

我发现一篇关于它的文章

编辑:似乎有一个解释页面:https://renenyffenegger.ch/notes/Windows/registry/tree/HKEY_CURRENT_USER/Control-Panel/International/index

原作者找到了以下解决方案,将第一部分更改为您的 de-DE:

$DefaultHKEY = "HKU\DEFAULT_USER"
$DefaultRegPath = "C:\Users\Default\NTUSER.DAT"
Set-Culture de-DE
Set-WinSystemLocale de-DE
Set-WinHomeLocation -GeoId 94 # Germany (see https://docs.microsoft.com/de-ch/windows/win32/intl/table-of-geographical-locations)
Set-WinUserLanguageList de-DE
reg load $DefaultHKEY $DefaultRegPath
reg import ".\de-DE-default.reg"
reg unload $DefaultHKEY
reg import ".\de-DE-welcome.reg"

和注册表文件:

Windows Registry Editor Version 5.00

[HKEY_USERS\DEFAULT_USER\Control Panel\International]
"Locale"="00000407" ; source: https://renenyffenegger.ch/notes/Windows/development/Internationalization/language#windows-language-id
"LocaleName"="de-DE"
;"s1159"="AM"
;"s2359"="PM"
"sCountry"="Germany"
"sCurrency"="€"
"sDate"="/"
"sDecimal"="."
"sGrouping"="3;0"
"sLanguage"="ENG"
"sList"=","
"sLongDate"="dd MMMM yyyy"
"sMonDecimalSep"="."
"sMonGrouping"="3;0"
"sMonThousandSep"=","
"sNativeDigits"="0123456789"
"sNegativeSign"="-"
"sPositiveSign"="+"
"sShortDate"="dd/MM/yyyy"
"sThousand"=","
"sTime"=":"
"sTimeFormat"="HH:mm:ss"
"sShortTime"="HH:mm"
"sYearMonth"="MMMM yyyy"
"iCalendarType"="1"
"iCountry"="44"
"iCurrDigits"="2"
"iCurrency"="0"
"iDate"="1"
"iDigits"="2"
"NumShape"="1"
"iFirstDayOfWeek"="0"
"iFirstWeekOfYear"="2"
"iLZero"="1"
"iMeasure"="0"
"iNegCurr"="1"
"iNegNumber"="1"
"iPaperSize"="9"
"iTime"="1"
"iTimePrefix"="0"
"iTLZero"="1"

[HKEY_USERS\DEFAULT_USER\Control Panel\International\Geo]
"Nation"="242"

[HKEY_USERS\DEFAULT_USER\Control Panel\International\User Profile]
"Languages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00
"ShowAutoCorrection"=dword:00000001
"ShowTextPrediction"=dword:00000001
"ShowCasing"=dword:00000001
"ShowShiftLock"=dword:00000001

[HKEY_USERS\DEFAULT_USER\Control Panel\International\User Profile\en-GB]
"CachedLanguageName"="@Winlangdb.dll,-1110"
"0809:00000809"=dword:00000001

[HKEY_USERS\DEFAULT_USER\Control Panel\International\User Profile System Backup]
"Languages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00
"ShowAutoCorrection"=dword:00000001
"ShowTextPrediction"=dword:00000001
"ShowCasing"=dword:00000001
"ShowShiftLock"=dword:00000001

[HKEY_USERS\DEFAULT_USER\Control Panel\International\User Profile System Backup\en-GB]
"CachedLanguageName"="@Winlangdb.dll,-1110"
"0809:00000809"=dword:00000001

[HKEY_USERS\DEFAULT_USER\Keyboard Layout]

[HKEY_USERS\DEFAULT_USER\Keyboard Layout\Preload]
"1"="00000809"

[HKEY_USERS\DEFAULT_USER\Keyboard Layout\Substitutes]

[HKEY_USERS\DEFAULT_USER\Keyboard Layout\Toggle]

[HKEY_USERS\DEFAULT_USER\Control Panel\Desktop\MuiCached]
"MachinePreferredUILanguages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00,00,00

[HKEY_USERS\DEFAULT_USER\Control Panel\Desktop]
"PreferredUILanguages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00
Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Control Panel\International]
"Locale"="00000809"
"LocaleName"="en-GB"
"s1159"="AM"
"s2359"="PM"
"sCountry"="United Kingdom"
"sCurrency"="£"
"sDate"="/"
"sDecimal"="."
"sGrouping"="3;0"
"sLanguage"="ENG"
"sList"=","
"sLongDate"="dd MMMM yyyy"
"sMonDecimalSep"="."
"sMonGrouping"="3;0"
"sMonThousandSep"=","
"sNativeDigits"="0123456789"
"sNegativeSign"="-"
"sPositiveSign"="+"
"sShortDate"="dd/MM/yyyy"
"sThousand"=","
"sTime"=":"
"sTimeFormat"="HH:mm:ss"
"sShortTime"="HH:mm"
"sYearMonth"="MMMM yyyy"
"iCalendarType"="1"
"iCountry"="44"
"iCurrDigits"="2"
"iCurrency"="0"
"iDate"="1"
"iDigits"="2"
"NumShape"="1"
"iFirstDayOfWeek"="0"
"iFirstWeekOfYear"="2"
"iLZero"="1"
"iMeasure"="0"
"iNegCurr"="1"
"iNegNumber"="1"
"iPaperSize"="9"
"iTime"="1"
"iTimePrefix"="0"
"iTLZero"="1"

[HKEY_USERS\.DEFAULT\Control Panel\International\Geo]
"Nation"="242"

[HKEY_USERS\.DEFAULT\Control Panel\International\User Profile]
"Languages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00
"ShowAutoCorrection"=dword:00000001
"ShowTextPrediction"=dword:00000001
"ShowCasing"=dword:00000001
"ShowShiftLock"=dword:00000001

[HKEY_USERS\.DEFAULT\Control Panel\International\User Profile\en-GB]
"CachedLanguageName"="@Winlangdb.dll,-1110"
"0809:00000809"=dword:00000001

[HKEY_USERS\.DEFAULT\Control Panel\International\User Profile System Backup]
"Languages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00
"ShowAutoCorrection"=dword:00000001
"ShowTextPrediction"=dword:00000001
"ShowCasing"=dword:00000001
"ShowShiftLock"=dword:00000001

[HKEY_USERS\.DEFAULT\Control Panel\International\User Profile System Backup\en-GB]
"CachedLanguageName"="@Winlangdb.dll,-1110"
"0809:00000809"=dword:00000001

[HKEY_USERS\.DEFAULT\Keyboard Layout]

[HKEY_USERS\.DEFAULT\Keyboard Layout\Preload]
"1"="00000809"

[HKEY_USERS\.DEFAULT\Keyboard Layout\Substitutes]

[HKEY_USERS\.DEFAULT\Keyboard Layout\Toggle]

[HKEY_USERS\.DEFAULT\Control Panel\Desktop\MuiCached]
"MachinePreferredUILanguages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00,00,00

[HKEY_USERS\.DEFAULT\Control Panel\Desktop]
"PreferredUILanguages"=hex(7):65,00,6e,00,2d,00,47,00,42,00,00,00

相关内容