Reputation: 160
I am new to Powershell and I have searched the internet for whole day but still cannot find out how to customize "Region and Language" settings using Powershell in win7 or win2008.
I want to change the following settings within Powershell:
Current System Locale
Short Date and Long Date format
Short Time and Long Time format
Current Location
Anybody knows how to do that using Powershell? Cmd/Bat/.NET solutions also welcome!
Upvotes: 4
Views: 32831
Reputation: 8410
@bourne lead me to
& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"c:\setKeyboardUK.xml`""
Note the lack of a space between the ,, and /f, the use of quotes around the whole thing and the back tick to escape the quotes around the path (that are necessary).
This is my setKeyboardUK.xml file
<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
<!--User List-->
<gs:UserList>
<gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" CopySettingsToSystemAcct="true"/>
</gs:UserList>
<gs:UserLocale>
<gs:Locale Name="en-GB" SetAsCurrent="true"/>
</gs:UserLocale>
<!--location-->
<gs:LocationPreferences>
<gs:GeoID Value="242"/>
</gs:LocationPreferences>
<gs:InputPreferences>
<!--en-GB-->
<gs:InputLanguageID Action="add" ID="0809:00000809" Default="true"/>
</gs:InputPreferences>
To check if the settings are applied(because failures are silent) open Event Viewer and "Application and Services Logs" then "Microsoft", "Windows", "International","Operational" any successful changes or failures are logged here(the logging is enabled by default).
FYI I did all this on Powershell 3 on Windows 2008 R2 64bit. YMMV
Upvotes: 4
Reputation: 1803
I know your question was about Windows 7; this information may be helpful for those now running newer versions. Set-WinUserLanguageList
, New-WinUserLanguageList
and Get-WinUserLanguageList
in Windows 8 and up let you control the installed languages. For example to add a language:
$list = Get-WinUserLanguageList
$list.Add("fr-FR")
Set-WinUserLanguageList $list
Set-Culture
in PowerShell 3 lets you change culture, for example to choose defaults for Germany:
Set-Culture de-DE
Or, to set custom formats:
$culture = Get-Culture
$culture.DateTimeFormat.ShortDatePattern = 'yyyy-MM-dd'
$culture.DateTimeFormat.LongDatePattern = 'dddd, d MMMM yyyy'
$culture.DateTimeFormat.ShortTimePattern = 'h:mm tt'
$culture.DateTimeFormat.LongTimePattern = 'h:mm:ss tt'
Set-Culture $culture
To change the location, use Set-WinHomeLocation
, for example to set the user's location to Austria:
Set-WinHomeLocation -GeoId 14
MSDN has a list of GeoIds and a TechNet has a reference for international settings cmdlets.
Upvotes: 6
Reputation: 259
Hey I know this is kind of old, but I had to do the same but I did it in a batch script. I am now currently trying to figure out how to do it in powershell.
Check out my post here - https://superuser.com/questions/353752/windows-7-change-region-and-language-settings-using-a-script
The same should apply in Powershell using the following command:
PS C:\> & $env:SystemRoot\System32\control.exe "intl.cpl,, /f:path\to\xml\file\change_system_region_to_US.xml"
However, for me it doesn't work for some reason even though the command executes without error, the changes don't actually take effect.
If you run the same command from a standard CMD window, the changes take effect immediately. And if you remote the quotations to match the way you would run it in a CMD window you get the following error:
PS C:\> & $env:SystemRoot\System32\control.exe intl.cpl,, /f:"path\to\xml\file\change_system_region_to_US.xml"
Missing argument in parameter list.
At line:1 char:50
+ & $env:SystemRoot\System32\control.exe intl.cpl,, <<<< /f:"path\to\xml\file\change_system_region_to_US.xml"
+ CategoryInfo : InvalidOperation: (,:String) [], RuntimeException
+ FullyQualifiedErrorId : MissingArgument
Powershell doesn't appear to like the comma's very much.
Doing so in a .bat file though works like a charm. Just make sure you get your country codes and stuff right. It might require a little tinkering to get the .xml file to change the parameters you want.
Upvotes: 1