[Solved] What .batch command to check the currently used language on the system?

Discussion in 'Scripting' started by RemixPL1994, Mar 1, 2021.

  1. RemixPL1994

    RemixPL1994 MDL Junior Member

    Jul 16, 2017
    52
    6
    0
    #1 RemixPL1994, Mar 1, 2021
    Last edited: Mar 1, 2021
    Hello. What .batch command to check the currently used language on the system? (not default language) I have a code that 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

    [​IMG][​IMG]

    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?

    If I can, please let me know @abbodi1406

    Best regards ;)
     
  2. Tux 528

    Tux 528 MDL Novice

    Apr 20, 2020
    9
    11
    0
    Hi!

    Maybe you can test this code:
    Code:
    FOR /F "skip=2 tokens=2*" %a IN ('REG QUERY "HKEY_CURRENT_USER\Control Panel\International" /v "LocaleName"') DO SET "OSLanguage=%b"
    IF "%OSLanguage%"=="pl-PL" (
    echo Polish was detected.
    )
    pause
    EXIT
    Best regards
     
  3. RemixPL1994

    RemixPL1994 MDL Junior Member

    Jul 16, 2017
    52
    6
    0
    #3 RemixPL1994, May 16, 2021
    Last edited: May 16, 2021
    (OP)
    @Tux 528 Welcome. I only noticed this message because I had not seen it before, I did not receive a notification. I checked this code and unfortunately it does not work for me because it does not execute after copying and pasting it into a .bat / cmd script. The console starts up and shuts down instantly without any displayed information. Of course I removed "EXIT" at the end and left the "PAUSE" command alone, but that doesn't work.
     
  4. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,226
    84,914
    340
    @RemixPL1994
    use double %% in batch script
    Code:
    FOR /F "skip=2 tokens=2*" %%a IN ('REG QUERY "HKEY_CURRENT_USER\Control Panel\International" /v "LocaleName"') DO SET "OSLanguage=%%b"