How can I find the current Windows language from cmd?

前端 未结 8 1061
囚心锁ツ
囚心锁ツ 2021-02-04 12:02

I would like to run a script for each language. I need a way to find which os language is being used, using batch files. Both on windows XP, and on Windows 7.

相关标签:
8条回答
  • 2021-02-04 12:19

    Don't know if this still works on Windows 7 but it does in Windows XP

    reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage
    

    Then you can parse the ouput. e.g.

    0409 --> English
    0407 --> German
    
    0 讨论(0)
  • 2021-02-04 12:24

    In console CMD write command:

    intl.cpl

    0 讨论(0)
  • 2021-02-04 12:24

    Use a command on cmd and search for english word(s) associate with your query.

    Example: w32tm /query /peers >> somewhere.txt

    #Peers: 1
    
    Peer: ca.pool.ntp.org
    State: Active
    Time Remaining: 58.3260171s
    Mode: 3 (Client)
    Stratum: 3 (secondary reference - syncd by (S)NTP)
    PeerPoll Interval: 17 (out of valid range)
    HostPoll Interval: 10 (1024s)
    

    The first line is always "peers" or "service not started", so if the user is on an other language than english the script will not find this word and the result can return 0.

    0 讨论(0)
  • 2021-02-04 12:27

    in cmd: reg query "HKEY_CURRENT_USER\Keyboard Layout\Preload"

    this produces:

    HKEY_CURRENT_USER\Keyboard Layout\Preload
        2    REG_SZ    00000419
        1    REG_SZ    00000809
    

    like the first answer you then parse the rightmost numbers using this or this site

    if the left most number is number 1 that is the current keyboard language in use currently.

    0 讨论(0)
  • 2021-02-04 12:29

    You can't use InstallLanguage under HKLM\SYSTEM\CurrentControlSet\Control\nls\language
    because that's just what it says it is: Install Language
    Although you can directly install localized version of Windows, this is not always done, as it wasn't on my PC. Instead a language pack is applied, which is fine, but then Display Language is not the same as Install Language.
    Also if a user change his display language, InstallLanguage will not reflect the change. And there could be more users with different display languages.

    • Current User Display Language

    HKCU\Control Panel\Desktop
    PreferredUILanguages

    FOR /F "tokens=3" %%a IN ('reg query "HKCU\Control Panel\Desktop" /v PreferredUILanguages ^| find "PreferredUILanguages"') DO set UILanguage=%%a
    echo User Display Language: %UILanguage%
    


    There is difference between Local Machine language, System language and User language. There is also separate settings for BCD language, used for recovery and boot manager

    • Local Machine

    Install language is set upon installation and is never changed
    also a Default value for "HKLM\SYSTEM\CurrentControlSet\Control\nls\language" key is set to the same value. This value is wrongly read by some InstallShield setup programs, resulting in English interface on localized Windows.
    If you change Display language, new value is stored in

    HKLM\SYSTEM\CurrentControlSet\Control\MUI\Settings
    PreferredUiLanguages

    this will override InstallLanguage value under HKLM\SYSTEM\CurrentControlSet\Control\nls\language
    There is a mix-up in value types, while InstallLanguage is LCID, PreferredUiLanguages is LCID string. This language is then reported as Local Machine Language. It isn't User Display Language

    • System Language

    This is the language for System user.
    Before a user is logged on, this language is used.
    That means it is a language for Welcome screen, and for the OOBE.

    HKEY_USERS\S-1-5-18\Control Panel\Desktop\MuiCached
    MachinePreferredUILanguages



    There is also a WMI way to get OS language, but I didn't test which of these languages you'll get

    wmic os get locale, oslanguage, codeset

    FOR /F "tokens=2 delims==" %%a IN ('wmic os get OSLanguage /Value') DO set OSLanguage=%%a
    echo OS Language: %OSLanguage%
    
    0 讨论(0)
  • 2021-02-04 12:30

    Use "dism /online /get-intl" command.

    0 讨论(0)
提交回复
热议问题