Windows 10 Unattended install media – Part 5: Sysprep & Capture Image


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.

Sysprep

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.

Make ISO

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:

Click to view enlarged in a new tab.

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\, 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:

 

Kari

Author: Kari Finn

A former 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.

50 thoughts on “Windows 10 Unattended install media – Part 5: Sysprep & Capture Image

  1. naturally like your website but you have to check the spelling on several of your posts. Many of them are rife with spelling problems and I find it very bothersome to tell the truth nevertheless I’ll definitely come back again.

  2. I dont really know what you are using the Asset Share for with the setup files or maybe I missed something?
    Where do you say the Process to install these files?

    Thank you very much for the Tutorial!

  3. I am using the Assets share to transfer installers and other files to reference machine.

    While Windows installs on reference machine, I’ll prepare the Assets folder on technician machine sharing it. When reference machine is booted to Audit Mode, I have fast and easy access to various installers, themes and other files on the shared Assets folder.

    It’s much faster and simpler than to download everything needed on reference machine.

  4. Hi, as my understanding,this is the process to create the USB installation media.How about the boot image if we use WDS?

  5. This series of posts does not show how to create a USB install media for unattended install, it shows how to create an ISO image.

    At the end of this Part 5, you will be told how to create a custom ISO image. You can use that for any available deployment method. To create a USB is one option, to use ISO in other deployment scenarios as such is another option.

  6. Kari, Great write-up. I have managed to use this completed custom ISO image to deploy another VM to prove it worked. The only interaction i had before Windows loaded was at the language screen settings where there was no option to change from the default Language to install ;English (United States).

    The ‘time and currency format’ and also ‘keyboard or input method’ settings were displayed as expected as EN-GB which is what i set them to in my answer file. Not sure why the language to install was not this as well though, is that due to the ISO i used? Should i have set the fallback language to EN-US in my answer file so this screen would not be displayed?

    Secondly. It would be great if you did a follow up video on how to deploy this custom image we have created out using WDS (if that is the preferred method these days). When testing, I try to add my custom .WIM file in WDS it says ‘the file does not contain a valid install image’.

    Keen to understand next steps on how we deploy this out to multiple machines via pxe at once to complete this series.

  7. @Emilie Dunomes — Why do you bothersome to tell the truth ?
    Also, I wonder why is it that misspelling irks you, but mispunctuation doesn’t phase you ?

  8. Kari, great article — though at my level it looks quite overwhelming, TBH. Once upon a time you’d just setup a workstation and run NortonGhost… done, (if only that still worked)!
    I would like to try this out, but I have some concerns about when/how to activate applications and licensing (can that be done before the ISO creation?); Could you go into more detail about the best practice for networking/IP setup (eg. my network has no domain at present, just a NAS and a dozen or so workstations)?
    Thanks.

  9. Thank you for this guide. Has been a great help but am having a problem when trying to import the WIM into WDS. I’m receiving a message stating that the WIM is not valid.

  10. Lee, it might be and most probably is my fault. Checking this post now, I noticed that I have for some reason added a totally unnecessary switch to the DISM command to capture the image. The command as it was in this post of mine is as follows:

    dism /Capture-Image /ImageFile:H:\Capture\install.wim /CaptureDir:I:\ /name:"W10PRO" /compress:maximum /checkintegrity /verify /bootable

    That very last switch /bootable is totally unnecessary. It does not cause any harm when image is used in traditional deployment, but from my own experience I know it can cause issues with WDS.

    I will edit the post immediately after posting this reply and remove that /bootable switch from command sample. Please try to capture the image again, this time with this command:

    dism /Capture-Image /ImageFile:H:\Capture\install.wim /CaptureDir:I:\ /name:"W10PRO" /compress:maximum /checkintegrity /verify

    You should now be able to import WIM file to WDS.

    My apologies.

    Kari

  11. Glorious! Thank you Kari! There is so much misinformation or outdated information or incomplete information about syspreping a Windows OS. Your 5 articles bring it all together and explain exactly how to do what we wanted to do.

    Works perfect! The Online support link in the OEM information doesn’t do anything but I’m guessing it’s a Windows 10 bug.

    Thanks again!

  12. Hi Kari, great article, thanks. However, when booting from the ISO (via USB), setup starts and then says: “Select the operating system you want to install. No images are available”.

    Any ideas?

    Thanks,

    Paul

    1. Hi Paul.

      There can be two reasons:
      1.) because the autounattended.xml file on root of the install media, in your case USB drive, is either wrong or missing information.
      2.) The captured custom install.wim is damaged, not valid.

      As uploading files and screenshots here in comments is not possible, and because I would need some of those from you, I would like to ask you to register on TenForums.com. I have published this series as a tutorial there, it would be much easier to try to assist you if you posted about your issue in the tutorial thread: https://www.tenforums.com/tutorials/96683-create-media-automated-unattended-install-windows-10-a.html

      Kari

  13. Hey Kari

    Thanks for an excellent tutorial,

    I’m am however stuck on dism /Capture-Image /ImageFile:H:\Capture\install.wim /CaptureDir:I:\ /name:”W10PRO” /compress:maximum /checkintegrity /verify

    obviously I changed the drive letter etc.

    I get error: 5
    access is denied

    please help

  14. Hey, never mind, I figured it out.
    Locations got scrambled, all good now.

    Thanks for the awesomeness!

  15. I was able to create a working Answer file from this step by step guide. Thank you!

    One follow up question regarding the 3 security questions (1803,1809) during oobe. Would this answer file skip those questions? Usually would you use skipmachineOOBE = true to by pass this?
    These settings are depreciated. Would those settings still work?
    I am are trying to skip the entire Cortana oobe setup.

    Thank you

  16. Hello Kari, thanks for the write up. It worked perfectly for me in 1709 OS builds. However, I’m trying to do the same in 1803 currently and I’m having a problem. When I sysprep using the unattend.xml file that is created, and I capture the wim file and add the newly captured wim to the sources folder of the install media, I get the error “Windows cannot find the Microsoft License Terms. Make sure the installation sources are valid and restart the installation.” Do you know what could be causing this issue? The only difference I’ve made is sysprepping the VM with the unattend.xml and replacing the existing wim file with the newly captured wim file.

    1. That error message simply means that there’s an error in answer file. Something is missing, not having seen your answer files I cannot answer to you.

  17. Hey Kari, need to ask another one, I tried using serva to install this image over pxe, but can’t get it working.
    what do you use for pxe, and can you maybe create an tutorial for this. Thanks

  18. Thanks for the quick response. I always validate the answer file before saving it and testing it, so I’m not sure what could be the problem. I’ve also done side by side comparisons of the answer file for 1803/1809 with my working answer file from 1709, is it possible something could be deprecated? Or maybe a licensing issue? I would be willing to share the answer file with you if you wouldn’t mind taking a look? Thanks again.

  19. if I skip the first few steps and only follow part 3 to create an unattend.xml file, place that in the sysprep folder on my vm. Sysprep with generalize and oobe and shut down, take a snapshot, then save the image to a usb drive with clonezilla, would I then be able to restore that image to workstations and have it skip through oobe?

    1. Yes. Autounattend.xml on root of install media is only required if you want to make partitioning and Windows Setup unattended, automatic. If that is not required, you just need the unattend.xml for OOBE. Doing exactly what you described will work.

  20. Hi Kari,

    Firstly, a great tutorial, it opened new horizon for novice like myself. I have literally followed your series of these five articles. I have some issues in the end.
    This is how I proceeded with this:
    1. Downloaded 64 bit Windows 10 Release 1809 in .Iso format
    2. Used Windows System Image Manager to load install.wim from above iso and created the answer file as mentioned in this tutorial.
    3. Used the same Windows 10 iso image to install into Hyper V Virtual Machine as mentioned here.
    4. Added all required files and folders in specified paths
    5. Installed all third party tools (having no association with user profiles)
    6. Created the checkpoint
    7. Made all changes as advised in these tutorials
    8. Created iso as advised.
    Then I used the updated ISO of windows 10 in a new virtual machine to test. Unfortunately, it asked me to press key to boot, and prompted me with the following screen

    Once information is updated and next is clicked, it asked me to click on install now as shown below

    Then it asked me for the key

    Eventually I see the following error message

    WINDOWS COULD NOT DISPLAY IMAGES FOR INSTALLATION

    Following is the directory structure of iso I created

    Highlighted is the new install.wim files extracted.

    I shall be grateful if you can provide me some insight into this.

    PS: i am not able to add screenshots, i am happy to provide in an email if it can be helpful.

    Thanks
    Mohsin

  21. Kari thank you! I know have a more or less hardware agnostic reference image, that goes through oobe exactly the way I want. Only one thing for me left to tackle is drivers. Would I be able to add the ability to my unattend.xml file in the sysprep folder to install drivers off of a network share? if so how do I get it to only grab the drivers it would need for the specific model I imaged? Not sure if this makes sense? I have a bunch of different models of hardware in my organization, and id like a way for windows to automatically install the drivers from a network cache after the image has been restored to any particular device.

  22. I don’t really understand that process. Would I be adding drivers for each and every model to my image? if so would windows be able to pick out which ones it needs depending on the devices present? Or would I be literally creating a new image for each model with the corresponding drivers installed? if its the latter, that is kind of bringing me back to where I began, lots of individual images that I need to try and update every month.

    1. Yes, you can add drivers for multiple hardware setups. Read this section, it tells how to add multiple drivers: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-and-remove-drivers-to-an-offline-windows-image#add-drivers-to-an-offline-windows-image-by-using-an-unattended-answer-file

      Having said that, WIndows 10 is really good in finding correct drivers. I have not manually added any drivers to my images in past two years. When Windows 10 is deployed from my custom hardware independent image, Windows has found correct drivers on all devices during the setup phase.

  23. I followed this step by step. Everything went perfect, until I went to use my new iso. Upton boot up it came to the “Windows Setup” screen and said “No images are available”.

    sigh… did I miss some little step somewhere?

    1. Please don’t take this wrong: The instructions as told in this series are tested in real life scenarios so incredibly many times, that I am really confident saying that if everything is done as told in these posts, it works.

      Having said that, as uploading files and screenshots here in comments is not possible, and because I would need some of those from you, I would like to ask you to register on TenForums.com. I have published this series as a tutorial there, it would be much easier to try to assist you if you posted about your issue in the tutorial thread: https://www.tenforums.com/tutorials/96683-create-media-automated-unattended-install-windows-10-a.html

      Kari

  24. Thank you and no worries about offending me. As I’m sure that it was me who missed something somewhere. Which is why I’m in the middle of starting over from scratch and following the steps again.

    I will register and take a look at your tutorial.

    thanks!

    Jim

  25. When sysprep run this error appears after a few minutes :

    “A fatal error occured while trying to sysprep the machine”

    It’s with a version 1809 latest patches applied

    Any idea ?

  26. I found the problem.
    Need to disable the store.

    REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /v AutoDownload /t REG_DWORD /d 2 /f
    REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f

    Sysprep

    Then enable the store after success :

    REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /v AutoDownload /t REG_DWORD /d 4 /f
    REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /t REG_DWORD /d 0 /f

    Not sure if needed but I have also disable internet access with a firewall outboud rule :

    New-NetFirewallRule -DisplayName "Block Outgoing 80, 443" -Enabled True -Direction Outbound -Profile Any -Action Block -Protocol TCP -RemotePort 80,443

    Enable internet after sysprep :

    Get-NetFirewallRule -DisplayName "Block Outgoing 80, 443" | Remove-NetFirewallRule

    1. Sysprep with /generalize switch failing is most often caused by app provisioning. This became an issue in W10 version 1709 and later, because Microsoft changed how built-in admin account works. Earlier, it was not possible to use any UWP apps with built-in admin account, but since version 1709, you can use it as any normal user account, even switch it to a Microsoft account. I wrote about this bad decision earlier: This is wrong, Microsoft: Built-in Admin as MSA. As UWP apps including Store now work in built-in admin account, as soon as Store updates a single app, provisioning happens and Sysprep gets generalizing issues. Setupact.log file will show which app caused Sysprep to fail.

      Log files can be found in Panther folder:

      C:\Windows\System32\Sysprep\Panther

      My solution to avoid this is simple, although I am fully aware it does not suit all users / IT admins: In my deployment images, I remove all native Windows UWP apps except Windows Store before sysprepping. First, I remove all apps from current built-in admin account I am using to customize image in Audit Mode with following command in elevated PowerShell:

      Get-AppxPackage -AllUsers | where-object {$_.name –notlike '*store*'} | Remove-AppxPackage

      Next, I do the same for all future user accounts:

      Get-appxprovisionedpackage –online | where-object {$_.packagename –notlike '*store*'} | Remove-AppxProvisionedPackage -online

      These two commands give a nice and clean Start menu:

      null

  27. Thanks Kari for your precisions.

    As you said your solution is not appropriate in IT environment where some appx are needed.

    I have an other issue.
    The customized image is greater than the maximum file size allowed on fat32. Fat32 is needed when using UEFI.
    How can I make a bootable USB key with that restriction ?

  28. Hi Kari,
    Thank you so much for the great tutorial! It’s very helpful.

    I did followed everything as in the tutorial except the fact that
    1) I was not able resist the installed apps from opening automatically. After installation, apps like notepad++, vscode and docker were opened automatically.
    2) I restarted the VM in audit mode. Because i enabled a windows feature called Hyper-V, which made the VM to reboot.
    3) At the end of the tutorial what i get is an iso with install.wim in the sources folder. The installation with this iso didn’t worked. So I converted this install.wim to install.esd using DISM command. Then created iso with that installe.esd file.

    These are the extra steps which i did. But at the time of installation from bootable USB, in setup, an error occurred ” no images available for installation”. I tried the installation again after removing the answer files. Still the error occurs.
    Could you please help me Kari??

  29. Tnx for the tutorial. I have a question. Where should I enable windows features like containers, Hyper-V or WinRM ?

  30. Windows 10 v1903 ISO file does not contain install.wim anymore. It uses install.esd (which has inside the .wim file)
    How do we convert to install.esd or capture straight to ESD file?

  31. I have the exact same issue, and went through the tutorial all over again to doublecheck if i missed anything, haha.

    Same Issue still. By far the best tutorial of unattended Install of Win10, i have come across with insight comments to further the understanding of each step.

    But I’t ain’t working still, I need a break.

    1. What is your issue? This procedure is so 100% sure, tested countless times, that it works if the instructions are followed to the letter.

  32. I replied to Mohsin Malik regarding the error message : “WINDOWS COULD NOT DISPLAY IMAGES FOR INSTALLATION” at the dialog box where choosing OS. In this case “Windows 10 Pro”, and my reply dropped to the bottom of comments.

    I not doubting you, as you are very throrough, and organized in writing this tutorial. I now had my break, and am going through the tutorial for a third time. I am very thorough as well, and am bugging out because it aint working, hehe.

    I reset my NTFS permissions on my Data drive (D:), Changed map folders to shorter foldernames (without spaces) for backward compability an so forth just to be sure.

    I am having another go, and thanks for the quick reply :).

  33. Hi Kari,

    Is this ISO image bootable after copying to USB?

    Waichung

Comments are closed.

More Stories From Admin Tools

%d bloggers like this: