Final phase of this project is to sysprep customized Windows image, capture it to a WIM file, and create an ISO for completely automated installation.
Create a Checkpoint
On your reference Hyper-V VM, create a checkpoint before proceeding. Select Action > Checkpoint in Virtual Machine Connection window, name the checkpoint as you wish, click YES to save it:
Later when you Sysprep or capture the image, if something goes wrong, it simply does not work, or if the system presents an error message, you can restore the state of reference VM as it was when checkpointed. This process takes less than a minute, after which you can troubleshoot / fix the errors, and try again. Consider it a form of cheap and fast insurance, because that’s exactly how it works.
On the reference VM, browse to the C:\Windows\System32\Sysprep folder, run Sysprep.exe. Select System Cleanup Action > Enter System Out-of-Box Experience (OOBE), select Generalize, select Shutdown Options > Shutdown, then click OK to start Sysprep:
Sysprep will run and generalize the Windows image (make it hardware independent). Windows on the reference VM will be shut down when Sysprep is complete:
Depending on the size of the Windows image (installed software, customizations etc.), this can take anywhere from a very few minutes to as long as 10-15 minutes (seldom longer, but for a huge complex Windows installation that’s at least possible).
Capture the custom Windows image
Open Disk Management on your host machine. Attach the reference VM’s VHDX file (virtual hard disk):
Attach the VHDX (virtual hard disk file) from your reference VM to the host. In case you have made one or more checkpoints, when deciding which VHDX to attach, select All files and attach the last checkpoint file (checkpoint file extension is .avhdx). Check the file’s Date Modified timestamp to be sure you attach the most recent checkpoint created:
Set the VHDX or AVHDX file as read only:
File Explorer will automatically open the attached VHDX or AVHDX (checkpoint). Note the drive letter it gets. In my case, it got drive letter I:
On the host machine, open an elevated (Run as administrator) Command Prompt. Enter the following command, changing the path in /ImageFile: to wherever you’d like to save the captured install.wim file, and set /CaptureDir to the drive letter for your attached (mounted) VHDX or AVHDX file. Name it as you like (/Name:”AnyName”):
dism /Capture-Image /ImageFile:H:\Capture\install.wim /CaptureDir:I:\ /name:"W10PRO" /compress:maximum /checkintegrity /verify
In case you used a physical PC as your reference machine instead of a Hyper-V VM, see this support article on Microsoft Docs about how to capture a Windows image from such a machine: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/capture-images-of-hard-disk-partitions-using-dism
Be patient. Capturing an image is a resource eating process, on slower hardware it can take several minutes even for the progress bar to appear and start from 0%. On this laptop of mine, the whole capturing process takes about half an hour, progress bar appears first in about 10 minutes. On the other hand, on a fast i7 machine with an SSD, the whole process is done in couple of minutes.
Create a folder anywhere on your host, and name it ISO_Files (that’s the name I use, you can of course name the folder as you wish). Mount the Windows 10 ISO image you used to install Windows onto the reference machine as a virtual DVD drive (right click ISO > select Mount). In File Explorer, select the mounted ISO, copy its entire contents to the ISO_files folder.
Now, copy the autounattend.xml answer file you created in Part 2 to the root of the ISO_Files folder. Open the ISO_Files\Sources folder, and delete the install.wim file. Copy your custom install.wim file captured above into the same folder, thereby replacing the original. That’s the new customized image you’ll be installing!
In Part 2, when creating the answer file named autounattend.xml for Windows Setup, we installed the Windows ADK Deployment Tools. Part of those tools is the Windows Deployment and Imaging Tools Environment. Right click it in Start > W > Windows Kits, then select More > Run as administrator:
By default, it has a disturbingly long prompt. Run the command cd \ to jump to the root of C: drive, then enter following command to create your custom ISO:
oscdimg.exe -m -o -u2 -udfver102 -bootdata:2#p0,e,bH:\Iso_Files\boot\etfsboot.com#pEF,e,bH:\Iso_Files\efi\microsoft\boot\efisys.bin H:\ISO_Files D:\AnyName.iso
This line may break across multiple lines in your Web browser. It’s a single command, and a single line of code. Simply triple-click (like double click but click mouse left button rapidly three times in the code box) the command, right click it and select “Copy” to copy the whole thing into your paste buffer so you can paste it into Deployment and Imaging Tools Environment.
Here’s a screenshot of what this looks like when run in Deployment and Imaging Tools Environment window:
Notice that the OSCDIMG command switches have no spaces or other characters between a switch and its properties.For instance, the path to the boot files appears as bH:\Iso_Files\ (green highlight in the preceding command sample), where b is the switch and H:\ISO_Files\ is its target folder. Name the ISO as you wish with the extension .iso and select where to create and store it (that’s the red highlight in the preceding command sample).
That’s it folks! You have now created Windows install media for a totally automated, hands-free Boot & Forget installation of Windows 10. You can use this ISO as-is to install Windows from a network share, or copy it to a USB flash drive and boot a PC from it to install Windows 10 without any user interaction.
Please do not hesitate to ask any questions about anything covered in this series of stories. Simply post a comment with your questions here, or in any of its other parts (1-4).
Links to all five parts:
- Windows 10 Unattended install media – Part 1: The Basics (published 05-APR-2018)
- Windows 10 Unattended install media – Part 2: Answer file for Setup (published 07-APR-2018)
- Windows 10 Unattended install media – Part 3: Answer file for OOBE (published 09-APR-2018)
- Windows 10 Unattended install media – Part 4: Customize Windows Image (published 11-APR-2018)
- Windows 10 Unattended install media – Part 5: Sysprep & Capture Image (published 12-APR-2018)
Author: Kari Finn
A Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.