0

我正在尝试从 Windows 2012 Server 远程使用安装在本地计算机上的名为 Sunetplus 的软件。我只需要在命令提示符下运行一行来完成我必须做的事情(即在软件数据库中导入新数据)。该命令在我的机器上运行良好,并且设置为也可以在服务器上运行。唯一的问题是:当我使用此命令行时,软件正常启动但随后显示错误:

CurrentCulture and CurrentUICulture define not the same language

我调查了一下,发现我的服务器的 CurrentCulture 是fr-CH,而 CurrentUICulture 是en-US。所以我去了:

  • 控制面板
  • 更改日期、时间或数字格式
  • 更改FormatEnglish(United States)

...并再次运行命令行,胜利!

它没有问题。但我实际上是不允许这样做的,也不应该更改服务器的日期格式。

所以我尝试在 Powershell 脚本中运行我的命令行,使用此Using-Culture函数正确设置 CurrentCulture。

#using-culture is defined before this part of the code
using-culture en-US{
    #Command line to call Sunetplus and its parameters
    & "\\MyLocalComputer\BBT Software\Sunetplus\SunetplusConsole.exe" -import Config='\\MyLocalComputer\Script\autoImport.xml' Password=****

    [System.Threading.Thread]::CurrentThread
}
[System.Threading.Thread]::CurrentThread

当我使用 输出线程的 currentCulture 时[System.Threading.Thread]::CurrentThread,它​​被正确设置为en-US,但软件仍然显示相同的错误。

我还尝试联系该软件的开发人员,经过一番讨论后,我得到的唯一答案是“只需在本地机器上运行命令行,而不是在服务器上运行”。

也许我在我的 Powershell 脚本中做错了什么(这是我的第一个 PS 脚本),或者这只是一个失败的原因。如果有人有一个好主意,我会全神贯注 :) 很抱歉发了这么长的帖子,谢谢你的帮助!

4

0 回答 0