I have an Windows 7 image (WIM) that contains multiple architectures. I want to know the index number of an particular architecture, inside the image.
For example, the image contains (In no specific order):
I do not have the index number of any of the above versions.
I want to retrieve the index number of Windows 7 Professional x64 in my windows image file. How would I go about this:
So far, I've came up with:
if exist %TEMP%\scm (RD %TEMP%\scm /S /Q)
md %TEMP%\scm
for /L %%A IN (1, 1, 12) Do (
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:%%A > %TEMP%\scm\%%A.txt
Findstr "Windows 7 Ultimate" %Temp%\scm\%%A.TXT && Findstr "x64" %Temp%\scm\%%A.TXT > nul
IF %ERRORLEVEL% == 0 (ECHO "It is Windows 7 Ultimate x64")
)
pause
I'm getting the below output
H:\>for /L %A IN (1 1 12) Do (
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:%A 1>C:\Users\Tarak\AppData\Local\Temp\scm\%A.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\%A.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\%A.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:1 1>C:\Users\Tarak\AppData\Local\Temp\scm\1.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\1.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\1.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Starter
Description : Windows 7 Starter
Size : 8,072,604,598 bytes
Version : 6.1.7601
ServicePack Build : 17514
Files : 46887
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:2 1>C:\Users\Tarak\AppData\Local\Temp\scm\2.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\2.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\2.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Home Basic
Description : Windows 7 Home Basic
Size : 8,125,226,573 bytes
Version : 6.1.7601
ServicePack Build : 17514
Files : 47090
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:3 1>C:\Users\Tarak\AppData\Local\Temp\scm\3.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\3.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\3.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Home Premium
Description : Windows 7 Home Premium
Version : 6.1.7601
ServicePack Build : 17514
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:4 1>C:\Users\Tarak\AppData\Local\Temp\scm\4.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\4.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\4.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Professional
Description : Windows 7 Professional
Size : 8,447,825,392 bytes
Version : 6.1.7601
ServicePack Build : 17514
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:5 1>C:\Users\Tarak\AppData\Local\Temp\scm\5.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\5.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\5.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Ultimate
Description : Windows 7 Ultimate
Size : 8,607,765,255 bytes
Version : 6.1.7601
ServicePack Build : 17514
Edition : Ultimate
Files : 48718
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:6 1>C:\Users\Tarak\AppData\Local\Temp\scm\6.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\6.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\6.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Home Basic
Description : Windows 7 Home Basic
Size : 11,707,704,502 bytes
Version : 6.1.7601
ServicePack Build : 17514
Files : 64267
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:7 1>C:\Users\Tarak\AppData\Local\Temp\scm\7.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\7.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\7.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Index : 7
Name : Windows 7 Home Premium
Description : Windows 7 Home Premium
Version : 6.1.7601
ServicePack Build : 17514
Modified : 21-Apr-11 - 06:07:36
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:8 1>C:\Users\Tarak\AppData\Local\Temp\scm\8.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\8.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\8.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Professional
Description : Windows 7 Professional
Version : 6.1.7601
ServicePack Build : 17514
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:9 1>C:\Users\Tarak\AppData\Local\Temp\scm\9.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\9.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\9.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Details for image : h:\research\Win7x64\InstallWin7_aio\sources\install.wim
Name : Windows 7 Ultimate
Description : Windows 7 Ultimate
Version : 6.1.7601
ServicePack Build : 17514
Edition : Ultimate
Directories : 13735
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:10 1>C:\Users\Tarak\AppData\Local\Temp\scm\10.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\10.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\10.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Error: 87
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:11 1>C:\Users\Tarak\AppData\Local\Temp\scm\11.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\11.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\11.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Error: 87
"It is Windows 7 Ultimate x64"
0
H:\>(
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:12 1>C:\Users\Tarak\AppData\Local\Temp\scm\12.txt
Findstr "Windows 7 Ultimate" C:\Users\Tarak\AppData\Local\Temp\scm\12.TXT && Findstr "x64" C:\Users\Tarak\AppData\Local\Temp\scm\12.TXT 1>nul
IF 0 == 0 (ECHO "It is Windows 7 Ultimate x64" )
ECHO 0
)
Error: 87
"It is Windows 7 Ultimate x64"
0
Enable the delayed expansion
if you want to test directly the !errorlevel!
and you'll better use the /i
switch with findstr
:
Or use directly &&
:
@echo off
if exist %TEMP%\scm (RD %TEMP%\scm /S /Q)
md %TEMP%\scm
for /L %%A IN (1, 1, 12) Do (
dism /Get-WimInfo /WimFile:h:\research\Win7x64\InstallWin7_aio\sources\install.wim /index:%%A > %TEMP%\scm\%%A.txt
Find /i "Windows 7 Ultimate" "%Temp%\scm\%%A.TXT" && Find /i "Architecture : x64" "%Temp%\scm\%%A.TXT" && (
set "Index=%%A"
goto:next
)
)
exit/b
:next
ECHO "Windows 7 Ultimate x64" is in Index : %Index%