I am trying to get the current setted system-language under use of wmic
,
but i don´t know why my code here is kind of "broken"...
The readback info from wmic
contains a lot of spaces and CRLF´s
.
Therefore i wanted to cut all that out in the loop, but the syntax is not proper in my example...
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:MAIN
setlocal
call :Get_System_Language "lang"
echo lang=%lang%
pause
exit /b 0
:Get_System_Language
setlocal
::Windows Language Code Identifier
::1031 German Germany
::2057 English United Kingdom
::1033 English United States
set "language=NUL"
set /a num_languages=3
for /f "tokens=1,2 delims==" %%a in ('wmic os get OSLanguage /Value') do (
if "%%a" equ "OSLanguage" (
set "item_tmp=%%b"
set "value=!item_tmp:=!"
if "!value!" equ "1031" (
set "language=german_germany"
)
if "!value!" equ "2057" (
set "language=english_british"
)
if "!value!" equ "1033" (
set "language=english_american"
)
(endlocal
if "%~1" neq "" (set "%~1=!language!")
)
exit /b 0
)
)
exit /b 1
Do you see the Problem?
Thank´s a lot ;-)
Split by =
then one more loop to remove CRLF
Example:
@echo off
for /f "tokens=2*delims==" %%i in ('wmic os get OSLanguage /value') do for %%f in (%%i) do (
if "%%~f" == "1031" set "Lang=german_germany"
if "%%~f" == "2057" set "Lang=english_british"
if "%%~f" == "1033" set "Lang=english_american"
)
echo %Lang%