Get account language from batch? (windows 10)

Discussion in 'Windows 10' started by johnye_pt, Sep 7, 2015.

  1. johnye_pt

    johnye_pt MDL Addicted

    Aug 26, 2010
    741
    377
    30
    I'm trying to read the account language to a variable within a batch file. It can be in text (en-US), hex (0x0409) or decimal (1033), preferably the first. I've tried WMIC but could only find commands for the OS Language:
    "WMIC OS GET LOCALE" returns 0816
    "WMIC OS GET LOCALE" returns 2070

    Both language codes correspond to pt-PT or Portugal, which is the original OS language, but my current account is in English with International settings for Portugal (timezone, currency, etc).

    I also searched the Registry and found these values:
    [HKEY_CURRENT_USER\Control Panel\Desktop] PreferredUILanguages, REG_MULTI_SZ, en-US
    [HKEY_CURRENT_USER\Control Panel\International\User Profile] Languages, REG_MULTI_SZ, en-US

    Since these values are REG_MULTI_SZ and both Names are plural, does it mean they can contain more than one language, or is it safe to assume they will only contain one language with 2 to 5 characters (xx or xx-xx)?
     
  2. Compo

    Compo MDL Member

    Mar 29, 2011
    136
    106
    10
    #2 Compo, Sep 9, 2015
    Last edited by a moderator: Apr 20, 2017
    What result do you get if you use powershell from a batch file?
    Code:
    @For /F %%A In ('PowerShell -C $Host.CurrentUICulture.Name') Do @Set "UIC=%%A"
    @Echo=[%UIC%]
    @Timeout 5 1>Nul
     
  3. johnye_pt

    johnye_pt MDL Addicted

    Aug 26, 2010
    741
    377
    30
    That's exactly what I needed, thanks! The output is "en-US", exactly the language my account is using, and the exact output I need :worthy::worthy: