Batch command to check the currently used system language, (not the default language)

Viewed 840

Which batch command can I use to detect the currently used system language, (not the default language)?

I have code which checks the default system language and goes to a separate code depending on whether the detected language is Polish or another = English:

@echo OFF
FOR /F "tokens=2 delims==" %%l IN ('wmic os get OSLanguage /Value') DO set OSLanguage=%%l
IF %OSLanguage% == 1045 GOTO L_POLISH
IF %OSLanguage% NEQ 1045 GOTO L_ENGLISH

:L_POLISH
echo Polish was detected
pause
exit

:L_ENGLISH
echo English was detected
pause
exit

enter image description here

The problem is that if we install the system in e.g. Polish, and then change the language in the system to English, German, etc., the code will not detect and will not set/display and will not go to the code for the English version, but will detect the default Polish and go to Polish code.

What command can I use as a check to make the code verify the currently used version of the system language instead of the default language?

1 Answers

Im not too sure about cmd, but in powershell you may use Get-Culture.

The Get-Culture cmdlet gets information about the current culture settings. This includes information about the current language settings on the system, such as the keyboard layout, and the display format of items such as numbers, currency, and dates.

See Here: Get-Culture

And for user settings specifically, you can check Get-WinUserLanguageList.

The Get-WinUserLanguageList cmdlet returns the current user language settings. These settings include input method, spelling setting, text prediction setting, and handwriting input mode.

See Here:Get-WinUserLanguageList

...and when theres a Get, theres a Set. Hopefully this is what you were looking for, or if it can point you in the right direction!:)

Related