3

我是Powershell的新手,我搜索了整整一天的互联网,但仍无法找到如何使用Powershell自定义“区域和语言”设置win7或win2008。如何使用Powershell在win7或win2008中自定义“区域和语言”设置

我想在PowerShell中更改以下设置:

  1. 当前系统区域设置

  2. 短日期和长日期格式

  3. 时间短,长时间格式

  4. 当前位置

任何人都知道如何使用Powershell? Cmd/Bat/.NET解决方案也很受欢迎!

感谢先进!

回答

1

嘿,我知道这是有点旧,但我必须做同样的事情,但我在批处理脚本中做到了。 我现在正在试图找出如何在PowerShell中做到这一点。

这里看看我的帖子 - https://superuser.com/questions/353752/windows-7-change-region-and-language-settings-using-a-script

同样使用下面的命令在PowerShell中应适用:

PS C:\> & $env:SystemRoot\System32\control.exe "intl.cpl,, /f:path\to\xml\file\change_system_region_to_US.xml" 

但是,对我来说并没有出于某种原因,即使 命令工作执行没有错误,这些更改实际上不会生效。

如果从标准CMD窗口运行相同的命令,更改将立即生效。 如果你远程报价,以你在CMD窗口中运行的方式与您取得 以下错误:

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不会出现像逗号的非常多。

在.bat文件中这样做虽然像魅力一样。只要确保你的国家代码和正确的东西。它可能需要一些修补程序才能让.xml文件更改所需的参数。

3

@bourne导致我

& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"c:\setKeyboardUK.xml`"" 

注缺乏之间的空间,,和/ F,围绕整个事情引号的使用和反勾逃跑的路径周围的引号(这是必要的)。

这是我的setKeyboardUK。xml文件

<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> 

要检查应用设置(因为失败是沉默的)打开事件查看器和“应用程序和服务日志”,然后“微软”,“国际”,“操作”任何成功此处记录更改或失败(日志记录默认启用)。

仅供参考我在Windows 2008 R2 64位上的Powershell 3上做了所有这些。 YMMV

+1

为我工作。我发现如果以管理员身份运行,会改变默认设置(对于新用户),但不会对现有用户进行更改。如果您以非管理员用户身份运行,它将为该用户更改,但不会更改为默认值。在实施时请记住它。 – mhouston100 2015-08-13 22:50:32

3

我知道你的问题是关于Windows 7的;这些信息可能对那些现在运行较新版本的人有所帮助。 Set-WinUserLanguageList,New-WinUserLanguageListGet-WinUserLanguageList在Windows 8和以上,让你控制安装的语言。例如增加一种语言:

$list = Get-WinUserLanguageList 
$list.Add("fr-FR") 
Set-WinUserLanguageList $list 

Set-Culture在PowerShell中3让你改变文化,例如选择默认值德国:

Set-Culture de-DE 

或者,要设置自定义格式:

$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 

要更改位置,请使用Set-WinHomeLocation,例如将用户的位置设置为奥地利:

Set-WinHomeLocation -GeoId 14 

MSDN有一个list of GeoIds和一个TechNet有international settings cmdlets的参考。

相关问题