13

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.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

10 Answers10

14

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
jitter
  • 53,475
  • 11
  • 111
  • 124
  • 1
    Thanks, jitter. this works on Windows 7 as well. you solved my problem. BTW: 040D --> Hebrew Thanks Speed –  Oct 23 '09 at 07:54
  • 1
    `040C -->` French; `0C0A -->` Spanish. – Alicia Jan 16 '17 at 14:31
  • 2
    Check this answer for more matchings between numeric code and language name in human format https://serverfault.com/a/310221 – jitter Nov 30 '19 at 10:01
  • 1
    This registry key is still present in Windows 10. All language codes (LCID) can be found here: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f – uranibaba Feb 03 '20 at 14:48
9

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%
papo
  • 1,606
  • 19
  • 18
  • 1. `wmic os get oslanguage` returns same value (in decimal) as `reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage` (in hexa). 2. If no preferred languages installed the reg query (/v PreferredUILanguages) returns an error both on reg query "HKCU\Control Panel\Desktop" – Gilles Maisonneuve Jun 06 '19 at 19:04
  • and on reg `query "HKLM\SYSTEM\CurrentControlSet\Control\MUI\Settings"` Complete solution might be yours with a fall back on initial install language if your reg query returns an error. Just my opinion. – Gilles Maisonneuve Jun 06 '19 at 19:11
4

The below code fixed my issue. It works on Windows Server 2003 and Windows 7

FOR /F "tokens=3 delims= " %%G in ('reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage') DO (
IF [%%G] EQU [0409] (
  ECHO English install language detected
) ELSE (
  ECHO Some other language detected
)

Hope it helps!

BlueEagle
  • 41
  • 1
  • 3
4

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

Sunny Shukla
  • 537
  • 1
  • 6
  • 17
1

In console CMD write command:

intl.cpl

Denis Bubnov
  • 2,619
  • 5
  • 30
  • 54
1

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.

user_number153
  • 492
  • 4
  • 7
1

Using powershell and tested on windows7 & windows10 (might works on XP but powershell is not native on XP)

No elevated command prompt necessary.

Syntax is given for command line execution

powershell get-uiculture

or

powershell -NoProfile "Get-UICulture|select -ExpandProperty LCID"

or

Last one works only for windows10.

powershell [CultureInfo]::InstalledUICulture

Credits/ref:

https://winaero.com/find-default-system-language-windows-10/ and

may i know the difference between [cultureinfo]::InstalledUICulture and get-uiculture in powershell?

1

there are two ways to do so using command prompt in windows

First

  • open elevated command prompt
  • type the following command dism /online /get-intl

enter image description here

Second

  • open elevated command prompt
  • type the following command systeminfo

enter image description here

both of these works depends on your need

SAFE CODER
  • 41
  • 7
0

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.

John RPG
  • 11
  • 1
0

In Windows 10 1903, the current user's language setting seems to be found in "HKCU\Control Panel\International\LocaleName"

imoir
  • 11
  • 2