cls cd /d "%~dp0" For %%i in (*.wim) Do call :_Mount "%%~dpnxi" Echo rd /s /q "%temp%\PePrograms">>"%temp%\UnMount.cmd" If not exist "%temp%\Programs" md "%temp%\Programs" GoTo :Eof :_Mount Set /a Count=0 :_1 md "%temp%\PePrograms\%~n1" imagex.exe /mountrw "%~1" 1 "%temp%\PePrograms\%~n1" if %errorlevel% LEQ 0 GoTo _2 imagex.exe /mount "%~1" 1 "%temp%\PePrograms\%~n1" if %errorlevel% LEQ 0 GoTo _2 Set /a Count+=1 if %Count% GEQ 50 GoTo _3 GoTo _1 :_2 echo imagex /unmount "%temp%\PePrograms\%~n1">>"%temp%\UnMount.cmd" :_3 GoTo :Eof