Reading a text fiile

Hi guys, hope you are all good and can assist.


We are using an Enterprise build with 10 or so language packs installed.
The user has the option at the start of the build to choose their language.

What we need to do is to trap what language they selected.
This is the Default system UI language.

In the case of that language being English, then the Default system UI language is en-US.

We can grab this by:

dism /online /get-intl > test.txt

The output of test.txt is in the code snippet below.

I have tried different language selections, and the value for  Default system UI language appears to be always on Line 9 in the text file.

So my question is.

Is there a way to read the test.txt file, and read a certain line number, in this case, line 9, and trap the value of Default system UI language into a variable?

I cannot do the folowing:

dism /Online /Get-Intl | find "Default system UI language"

This would work if the language chosen was English, but if the language chosen was Chinese for example, then

dism /Online /Get-Intl ^| find "Default system UI language"

would fail to find "Default system UI language" since the text is in Chinese.

Which is why I want to read line number 9, and find the value after the colon.

line9 (english) Default system UI language : en-US
line9 (german) <in german.....>: de-DE

So, something like,

1) read text file
2) read line number 9

if de-DE, then we know its German
if en-US, then we know its English
if es-ES, then we know its Spain
if fr-FR, then we know its France
if it-IT, then we know its Italy
if ja-JP, then we know its Japanese
if nb-NO, then we know its Norway
if pl-PL, then we know its Poland
if pt-BR, then we know its Brasil
if ru-RU, then we know its Russian
if zh-CN, then we know its Simplified Chinese
if zh-HK, then we know its Traditional Chinese

Any help greatly appreciated.
Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7600.16385

Reporting online international settings.

Default system UI language : en-US

Open in new window

Who is Participating?
The comments so far were always looking for the term "Default system UI language" which, according to your description, will fail on an installation with a non-"en-US" UI language:
line9 (english) Default system UI language : en-US
line9 (german) <in german.....>: de-DE

So here's a (currently rather verbose script for potential debugging) that will check for expected languages in given lines. it will exit with errorlevel 1 if the language couldn't be determined, 0 otherwise.
@echo off
REM *** space separated list of expected UI language tokens:
set ExpectedLanguages=de-DE en-US es-ES fr-FR it-IT ja-JP nb-NO pl-PL pt-BR ru-RU zh-CN zh-HK
REM *** space separated list of of line numbers in which to expect the language token:
set ExpectedLines=9
set SystemUILanguage=
for /f "tokens=1,2* delims=:" %%a in ('dism /online /get-intl ^| findstr /i /n "%ExpectedLanguages%"') do (
  echo Found language token in line %%a ^(%%b:%%c^).
  for %%l in (%ExpectedLines%) do (
    if "%%a"=="%%l" set SystemUILanguage=%%c
if "%SystemUILanguage%"=="" (
  echo Unexpected language, or output in unexpected line of "dism.exe".
  echo Expected languages:
  echo %ExpectedLanguages%
  echo Language expected in line^(s^):
  echo %ExpectedLines%
  exit /b 1
set SystemUILanguage=%SystemUILanguage: =%
echo System UI language found: %SystemUILanguage%

Open in new window

If you can use Windows Script Host's JScript, you're done.
Read the file, match with a RegExp and be happy.
Or is it not an option?
download grep for windows:

I created a text file called temp.txt with your data in it.  The result of the following command:

grep "Default system UI language :" deleteme.txt

Default system UI language : en-US

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Good ol' grep.
Next question would be how to isolate the sixth element after splitting the line using the space as delimiter.
Ok, download sed also:

grep "Default system UI language : \(.*\)" deleteme.txt | sed "s/Default system UI language : \(.*\)$/\1/"

yields: en-US

And I used deleteme.txt instead of temp.txt
You should also get GAwk for Windows to isolate the result. So you would go like this:
C:\> grep "Default system UI language :" deleteme.txt | gawk -F": " "{ print $2 }"

Open in new window

@rfportilla beat me to post ;-).

Use sed or gawk, but not both.
Sorry, @lexlythius.  You snooze, you lose.  ;-)
Simon336697Author Commented:
Guys thanks so much for your help.

The following works, but I get 1 space before "en-US". Is there any way to get rid of this?

for /f "tokens=1* delims=:" %a in ('dism /online /get-intl ^| find /N "en-US" ^| find "[9]"') do @echo %b

When you do it this way, you have to specify what you are looking for.  What if the language is not en-US?  The methods we were giving above don't require you to know the language.  If you need to use the command to produce this, you can use

dism /online /get-intl | grep "Default system UI language : \(.*\)" | sed "s/Default system UI language : \(.*\)$/\1/"

Ok, this is the last response you're getting from me:

for /f "tokens=5* delims= " %a in ('dism /online /get-intl  ^| find /N "Default" ^| find "[9]"') do @echo %b

Actually should be:

for /f "tokens=5* delims= " %a in ('type deleteme.txt ^| find /N "Default system UI language : " ^| find "[9]"') do @echo %b

Just to be on the safe side.
Ok, really, the last post.  Drop the find [9], just in case the output is changed and it no longer appears on the 9th line, this will work anyway:

for /f "tokens=5* delims= " %a in ('dism /online /get-intl ^| find /N "Default system UI language : "') do @echo %b
for /f "tokens=6" %a in ('dism /online /get-intl ^| find /I "Default system UI language : "') do @echo %a
Has this been resolved?  I think we have several viable answers here.  Please inform.  Thx.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.