[cmd scripts] Get-WinUserLanguageList using CMD

Discussion in 'Scripting' started by Dark Monkey, Jul 23, 2021.

  1. Dark Monkey

    Dark Monkey MDL Addicted

    Feb 2, 2011
    684
    836
    30
    #1 Dark Monkey, Jul 23, 2021
    Last edited: Jul 23, 2021
    Get-WinUserLanguageList using CMD call because i hate PS
    this code will actually show you real user language Id

    Code:
    @cls
    @echo off
    set SysLanIdHex=
    call :Get-WinUserLanguageList
    echo %SysLanIdHex%
    goto :eof
    
    :Get-WinUserLanguageList
    set xVal=&set xVal=%*
    if not defined xVal (
        for /f "tokens=3 delims= " %%g in ('reg query "HKEY_CURRENT_USER\Control Panel\International\User Profile" /v Languages ^| find /i "REG_MULTI_SZ"') do call :Get-WinUserLanguageList %%g
        goto :eof
    )
    for /f "tokens=1 delims=\0" %%g in ('echo %xVal%') do call :RegSubLangId %%g
    goto :eof
    :RegSubLangId
    REM echo key is %*
    REM reg query "HKEY_CURRENT_USER\Control Panel\International\User Profile\%*" | find /i "000"
    for /f "tokens=1 delims= " %%g in ('reg query "HKEY_CURRENT_USER\Control Panel\International\User Profile\%*" ^| find /i "000"') do call :RegSubLangIdExt %%g
    goto :eof
    :RegSubLangIdExt
    for /f "tokens=1 delims=:" %%g in ('echo %*') do set SysLanIdHex=%%g
    goto :eof
    Decided to make it more Nice to look
    Using EnableDelayedExpansion
    Code:
    @cls
    @echo off
    set xVal=
    set SysLanCD=
    set SysLanIdHex=
    call :Get-WinUserLanguageList_Warper
    do do do
    goto :eof
    
    :Get-WinUserLanguageList_Warper
    SETLOCAL EnableDelayedExpansion
    call :Get-WinUserLanguageList
    if defined SysLanIdHex call :convertLanHexToDec
    SETLOCAL DisableDelayedExpansion
    goto :eof
    
    :Get-WinUserLanguageList
    set xVal=
    set SysLanCD=
    set SysLanIdHex=
    for /f "tokens=3 delims= " %%g in ('reg query "HKEY_CURRENT_USER\Control Panel\International\User Profile" /v Languages ^| find /i "REG_MULTI_SZ"') do set xVal=%%g
    if defined xVal         (for /f "tokens=1 delims=\0" %%g in ('echo !xVal!') do set SysLanIdHex=%%g)
    if defined SysLanIdHex     (for /f "tokens=1 delims= " %%g in ('reg query "HKEY_CURRENT_USER\Control Panel\International\User Profile\!SysLanIdHex!" ^| find /i "000"') do set SysLanIdHex=%%g)
    if defined SysLanIdHex     (for /f "tokens=1 delims=:" %%g in ('echo !SysLanIdHex!') do set SysLanIdHex=%%g)
    goto :eof
    :convertLanHexToDec
    :: %%g=English %%h=1033 %%i=en-us %%j:0409
    for /f "tokens=1,2,3,4 delims=*" %%g in (tools\languages.ini) do (
        if     /i '%%j' EQU '!SysLanIdHex!' (
            set SysLanCD=%%i
            goto :convertLanHexToDec_
        )
    )
    :convertLanHexToDec_
    goto :eof
    Languages.ini
    Code:
    Afrikaans*1078*af-za*0436
    Albanian*1052*sq-al*041c
    Amharic*1118*am-et*045e
    Arabic*1025*ar-sa*0401
    Armenian*1067*hy-am*042b
    Assamese*1101*as-in*044d
    Azerbaijani*1068*az-latn-az*042c
    Bangla Bangladesh*2117*bn-bd*0845
    Bangla Bengali India*1093*bn-in*0445
    Basque Basque*1069*eu-es*042d
    Belarusian*1059*be-by*0423
    Bosnian*5146*bs-latn-ba*0141a
    Bulgarian*1026*bg-bg*0402
    Catalan*1027*ca-es*0403
    Chinese Simplified*2052*zh-cn*0804
    Chinese*1028*zh-tw*0404
    Croatian*1050*hr-hr*041a
    Czech*1029*cs-cz*0405
    Danish*1030*da-dk*0406
    Dari*1164*prs-af*048c
    Dutch*1043*nl-nl*0413
    English*1033*en-us*0409
    Estonian*1061*et-ee*0425
    Filipino*1124*fil-ph*0464
    Finnish*1035*fi-fi*040b
    French*1036*fr-fr*040c
    Galician*1110*gl-es*0456
    Georgian*1079*ka-ge*0437
    German*1031*de-de*0407
    Greek*1032*el-gr*0408
    Gujarati*1095*gu-in*0447
    Hebrew*1037*he-il*040d
    Hindi*1081*hi-in*0439
    Hungarian*1038*hu-hu*040e
    Icelandic*1039*is-is*040f
    Indonesian*1057*id-id*0421
    Irish*2108*ga-ie*083c
    Italian*1040*it-it*0410
    Japanese*1041*ja-jp*0411
    Kannada*1099*kn-in*044b
    Kazakh*1087*kk-kz*043f
    Khmer*1107*km-kh*0453
    KiSwahili*1089*sw-ke*0441
    Konkani*1111*kok-in*0457
    Korean*1042*ko-kr*0412
    Kyrgyz*1088*ky-kg*0440
    Latvian*1062*lv-lv*0426
    Lithuanian*1063*lt-lt*0427
    Luxembourgish*1134*lb-lu*046e
    Macedonian*1071*mk-mk*042f
    Malay*1086*ms-my*043e
    Malayalam*1100*ml-in*044c
    Maltese*1082*mt-mt*043a
    Maori*1153*mi-nz*0481
    Marathi*1102*mr-in*044e
    Mongolian*1104*mn-mn*0450
    Nepali*1121*ne-np*0461
    Norwedian Nynorsk*2068*nn-no*0814
    Norwegian Bokmal*1044*nb-no*0414
    Null*1033*en-us*0409
    Odia*1096*or-in*0448
    Persian*1065*fa-ir*0429
    Polish*1045*pl-pl*0415
    Portuguese Brazilian*1046*pt-br*0416
    Portuguese*2070*pt-pt*0816
    Punjabi*1094*pa-in*0446
    Quechua*3179*quz-pe*0c6b
    Romanian*1048*ro-ro*0418
    Russian*1049*ru-ru*0419
    Scottish Gaelic*1169*gd-gb*0491
    Serbian Bosnia*7194*sr-cyrl-ba*01c1a
    Serbian Serbia*10266*sr-cyrl-rs*0281a
    Serbian*9242*sr-latn-rs*0241a
    Sindhi Arabic*2137*sd-arab-pk*0859
    Sinhala*1115*si-lk*045b
    Slovak*1051*sk-sk*041b
    Slovenian*1060*sl-si*0424
    Spanish*3082*es-es*0c0a
    Swedish*1053*sv-se*041d
    Tamil*1097*ta-in*0449
    Tatar Cyrillic*1092*tt-ru*0444
    Telugu*1098*te-in*044a
    Thai*1054*th-th*041e
    Turkish*1055*tr-tr*041f
    Turkmen*1090*tk-tm*0442
    Ukrainian*1058*uk-ua*0422
    Urdu*1056*ur-pk*0420
    Uyghur*1152*ug-cn*0480
    Uzbek*1091*uz-latn-uz*0443
    Valencian*2051*ca-es-valencia*0803
    Vietnamese*1066*vi-vn*042a
    Welsh*1106*cy-gb*0452
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...