@echo off set SOURCES=%SystemDrive%\TEMP\W10\sources set WIM=%SOURCES%\install.wim set W10WIM=%SOURCES%\w10.wim set STATEFILE=%SOURCES%\w10done.txt if EXIST %STATEFILE% ( echo. echo [%0] INFO: found %STATEFILE% echo [%0] OK: nothing todo. all work was already done. echo READY. exit /b ) if EXIST %WIM% ( rem cleanup ... del /F %W10WIM% 1>nul 2>nul echo. echo [%0] INFO: found %WIM% echo [%0] INFO: exporting image from %WIM% ... dism /Export-Image ^ /SourceImageFile:%WIM% ^ /DestinationImageFile:%W10WIM% ^ /SourceIndex:1 ^ /Compress:Max ^ /CheckIntegrity if NOT EXIST %W10WIM% ( echo [%0] ERROR: while extracting %WIM% exit /b ) echo [%0] WARNING: removing original %WIM% ... attrib -R %WIM% 2>nul del /F %WIM% 1>nul 2>nul echo [%0] INFO: renaming %W10WIM% ... move /Y %W10WIM% %WIM% echo all done >%STATEFILE% echo. echo READY. exit /b )