开发者

How can I find the current Windows language from cmd?

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.


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


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%


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!


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


In console CMD write command:

intl.cpl


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.


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.


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


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

How can I find the current Windows language from cmd?

Second

  • open elevated command prompt
  • type the following command systeminfo

How can I find the current Windows language from cmd?

both of these works depends on your need


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜