There's two different ways of managing a diskpart.txt file. Each has their own pro's & con's.
1. Create a (long?) list of WinPE pass
RunSynchronousCommand's to sequentially echo each line of the diskpart.txt into a temporary file on the X:\ volume. Because autounattend.xml is copied to the ISO folder, no boot.wim modification is required.
Pro: Portable to every ISO, no copying of a file to the boot.wim
Con: Need a (long?) list of RunSynchronousCommands to create the file. Usually a hassle to update, because you need to preserve the
<Order> sequence.
2. Write all the diskpart commands to a file, and copy it to the boot.wim. All you need is one RunSynchronousCommand to execute "
diskpart /s \path\diskpart.txt".
Pro: Don't need to make autounattend.xml complicated, and too long because it has all these echo commands.
Con: Every time you need to update diskpart.txt, boot.wim must be mounted.
If you want a bare-minimum autounattend.xml to install Windows, without a Recovery partition:
Code:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>3</PartitionID>
</InstallTo>
</OSImage>
</ImageInstall>
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>cmd /c (for %a in ("sel disk 0" "cle" "con gpt" "cre par efi size=100" "for quick fs=fat32" "cre par msr size=16" "cre par pri" "for quick fs=ntfs") do @echo %~a) | diskpart</Path>
</RunSynchronousCommand>
</RunSynchronous>
<UserData>
<ProductKey>
<Key></Key>
</ProductKey>
</UserData>
</component>
</settings>
</unattend>
Every
<Command> is limited to a maximum of 251 chars, but two tricks can reduce the number of lines:
1. diskpart has command shortcuts, like "
cre par efi size=100" for "
create partition efi size=100".
2. "
exit" isn't required as the final command, since diskpart quits when reaching the end of the file, or reading from STDIN.