0

I'm trying to remotely use a software called Sunetplus installed on a local machine from a Windows 2012 Server. I only have to run a line in the command prompt to do what I have to do (which is import new data in the software database). The command works well on my machine and is set to work on the server as well. The only issue is this : when I use this command line, the software launches normally but then display an error :

CurrentCulture and CurrentUICulture define not the same language

I looked into it and found out that the CurrentCulture of my Server is fr-CH and the CurrentUICulture is en-US. So I went to:

  • ControlPanel
  • Language
  • Change date, time, or number formats
  • Changed the Format to English(United States)

... and ran the command line again, and victory!

It worked without a problem. But I am actually not allowed to do that and should never change the date format of the server.

So I tried to run my command line in a Powershell script, using this Using-Culture function to set the CurrentCulture properly.

#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

When I output the currentCulture of the thread using [System.Threading.Thread]::CurrentThread, it is correctly set to en-US, but the software still displays the same error.

I also tried to contact the developers of the software, and after some discussions the only answer I got was "Just run the command line on your local machine and not on the server".

Maybe I did something wrong in my Powershell script (it is my first PS script), or maybe it's just a lost cause. If anyone has a beautiful idea, I'm all ears :) Sorry for the long post, thank you for your help !

Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • I _think_ this may be due to the [call operator](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-6#call-operator-) running in a child scope. Perhaps [dot-sourcing](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-6#dot-sourcing-operator-) which runs in the current scope will work for you. – G42 Aug 05 '19 at 20:07
  • Improve the `Using-Culture` function by adding `[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture` (and appropriate backup and restore commands, of course). – JosefZ Aug 05 '19 at 21:05
  • If you change the culture in a script, the culture applies to that script process only - you're calling an executable which will run in another process. – Scepticalist Aug 06 '19 at 04:44
  • Thanks for the quick answers ! So I tried at first to change the `&` call operator by the `.` if I understood correctly what @gms0ulman told me and it dit not work, same error. @JosefZ Where should I add the instruction you mentionned in the function ? Not sure I understand what you meant by _appropriate backup and restore commands_ sorry... Would you mind explaining it to me ? – LuckyPoulpy Aug 06 '19 at 08:19

0 Answers0