Hi,
Hopefully this is the right place for my problem, if not please accept my apologies.
I have a device that uses the WIMBoot method - https://technet.microsoft.com/en-GB/library/dn594399.aspx
the device has four partitions, a 300MB System partition, 128MB MSR partions, OS Partition and a Recovery Partition.
I have created a DOS command batch program that runs from a WinPE USB, that takes an image of the device and saves it to the USB (no problems with that)
When I then use the Recovery option of my DOS command batch program it does the following;
Everything seems to have worked correctly, the system boots up .. however when I try to do a factory restore, removing everything it starts and then fails.
Any help would be appreciated.
Hopefully this is the right place for my problem, if not please accept my apologies.
I have a device that uses the WIMBoot method - https://technet.microsoft.com/en-GB/library/dn594399.aspx
the device has four partitions, a 300MB System partition, 128MB MSR partions, OS Partition and a Recovery Partition.
I have created a DOS command batch program that runs from a WinPE USB, that takes an image of the device and saves it to the USB (no problems with that)
When I then use the Recovery option of my DOS command batch program it does the following;
Code:
REM --- Constants used to calculate free space ---
REM Overhead Ratio: assume 6 MB overhead per 1000 MB size
set /a NTFS_OVERHEAD_RATIO=500/497
REM Per-Partition Overhead: 5 MB per partition
set /a NTFS_OVERHEAD_BASE=5
REM Megabytes-to-Millions Ratio:
REM This ratio converts values from megabytes to millions of bytes, approximately.
set /a mega_million_ratio=205/215
REM --------- Constants -------------
REM Drive letter of the Windows partition.
set user_volume=C:
REM Drive letter that contains \Images\install.wim. Example: E:
set wimfile_path=%directory%
REM Drive letter that contains \Images\winre.wim. Example: E:
set winre_wim_path=%directory%
for %%A in (%wimfile_path%\install.wim) do (
set install_wim_file_bytes=%%~zA
echo install.wim is [%install_wim_file_bytes%] bytes.
)
set /a install_wim_file_MB=%install_wim_file_bytes:~0,-6%+0
set /a install_wim_file_MB=%install_wim_file_MB%*205/215
for %%A in (%winre_wim_path%\winre.wim) do (
set winre_wim_file_bytes=%%~zA
echo winre.wim is [%winre_wim_file_bytes%] bytes.
)
set /a winre_wim_file_MB=%winre_wim_file_bytes:~0,-6%
set /a winre_wim_file_MB=%winre_wim_file_MB%*205/215
set /a more_size=500
set /a wim_partition_size_MB=%install_wim_file_MB%
set /a wim_partition_size_MB=%wim_partition_size_MB%+%winre_wim_file_MB%
set /a wim_partition_size_MB=%wim_partition_size_MB%+%more_size%
set /a wim_partition_size_MB=%wim_partition_size_MB%+%NTFS_OVERHEAD_BASE%
set /a wim_partition_size_MB=%wim_partition_size_MB%*500/497
echo Final Images partition size = {%wim_partition_size_MB%} MB
set wim_partition_letter=M:
echo. > %Drive%\DP1.TXT
echo select disk 0 >> %Drive%\DP1.TXT
echo clean >> %Drive%\DP1.TXT
echo convert gpt >> %Drive%\DP1.TXT
rem == 1. System partition (ESP)
echo create partition efi size=100 >> %Drive%\DP1.TXT
echo format quick fs=fat32 label="System" >> %Drive%\DP1.TXT
rem == 2. Microsoft Reserved (MSR) partition
echo create partition msr size=128 >> %Drive%\DP1.TXT
rem == 3. Windows partition
echo create partition primary >> %Drive%\DP1.TXT
echo shrink minimum=%wim_partition_size_MB% >> %Drive%\DP1.TXT
echo format quick fs=ntfs label="Windows" >> %Drive%\DP1.TXT
echo assign letter=%user_volume% >> %Drive%\DP1.TXT
rem === 4. Images partition
echo create partition primary >> %Drive%\DP1.TXT
echo format quick fs=ntfs label="Images" >> %Drive%\DP1.TXT
echo assign letter=%wim_partition_letter% >> %Drive%\DP1.TXT
echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" >> %Drive%\DP1.TXT
echo gpt attributes=0x8000000000000001 >> %Drive%\DP1.TXT
echo exit >> %Drive%\DP1.TXT
diskpart /s %Drive%\DP1.TXT
DEL %DRIVE%\DP1.TXT
md "%wim_partition_letter%\Windows Images\"
md %wim_partition_letter%\Recovery\WindowsRE
robocopy %wimfile_path%\ "%wim_partition_letter%\Windows Images\ " install.wim /s /copy:datso /dcopy:t
robocopy %winre_wim_path%\ %wim_partition_letter%\Recovery\WindowsRE\ winre.wim /s /copy:datso /dcopy:t
rem == Create a scratch directory for DISM operations
md %user_volume%\Recycler\Scratch
rem == Apply the Windows image to the Windows partition ==
Dism /Apply-Image /ImageFile:"%wim_partition_letter%\Windows Images\install.wim" /ApplyDir:%user_volume% /Index:1 /WIMBoot /ScratchDir:%user_volume%\Recycler\Scratch
rmdir %user_volume%\Recycler\Scratch
rem == Create boot files on the System partition ==
%user_volume%\Windows\System32\bcdboot %user_volume%\Windows
reagentc.exe /DISABLE
reagentc.exe /setreimage /path r:\Recovery\WindowsRE /target c:\Windows
reagentc.exe /ENABLE
Everything seems to have worked correctly, the system boots up .. however when I try to do a factory restore, removing everything it starts and then fails.
Any help would be appreciated.