w10install/image/export-image.cmd

52 lines
928 B
Batchfile
Raw Permalink Normal View History

2021-01-10 15:49:37 +01:00
@echo off
2023-02-20 07:56:50 +01:00
set SOURCES=%SystemDrive%\TEMP\W10\sources
2021-03-28 00:10:18 +01:00
set WIM=%SOURCES%\install.wim
2023-12-25 13:37:25 +01:00
set W10WIM=%SOURCES%\w10.wim
set STATEFILE=%SOURCES%\w10done.txt
2021-03-28 00:29:33 +01:00
2021-03-28 00:45:34 +01:00
if EXIST %STATEFILE% (
echo.
2021-03-28 11:54:06 +02:00
echo [%0] INFO: found %STATEFILE%
echo [%0] OK: nothing todo. all work was already done.
2021-03-28 00:45:34 +01:00
echo READY.
exit /b
)
2021-03-28 00:29:33 +01:00
if EXIST %WIM% (
2021-03-28 00:41:45 +01:00
rem cleanup ...
2023-12-25 13:37:25 +01:00
del /F %W10WIM% 1>nul 2>nul
2021-03-28 00:41:45 +01:00
2021-03-28 00:29:33 +01:00
echo.
2021-03-28 11:54:06 +02:00
echo [%0] INFO: found %WIM%
2021-03-28 00:29:33 +01:00
2021-03-28 11:54:06 +02:00
echo [%0] INFO: exporting image from %WIM% ...
2021-03-28 00:29:33 +01:00
dism /Export-Image ^
/SourceImageFile:%WIM% ^
2023-12-25 13:37:25 +01:00
/DestinationImageFile:%W10WIM% ^
/SourceIndex:1 ^
2021-03-28 00:32:53 +01:00
/Compress:Max ^
2021-03-28 00:29:33 +01:00
/CheckIntegrity
2023-12-25 13:37:25 +01:00
if NOT EXIST %W10WIM% (
2021-03-28 11:54:06 +02:00
echo [%0] ERROR: while extracting %WIM%
exit /b
)
2021-03-28 00:51:45 +01:00
2021-03-28 11:54:06 +02:00
echo [%0] WARNING: removing original %WIM% ...
attrib -R %WIM% 2>nul
del /F %WIM% 1>nul 2>nul
2023-12-25 13:37:25 +01:00
echo [%0] INFO: renaming %W10WIM% ...
move /Y %W10WIM% %WIM%
2021-03-28 00:29:33 +01:00
echo all done >%STATEFILE%
2021-01-10 15:49:37 +01:00
echo.
2021-03-28 00:29:33 +01:00
echo READY.
exit /b
)