With the answer files complete, now it’s time to install Windows 10 on a reference Hyper-V virtual machine. You can naturally use any other virtualization platform for this, or even a spare physical PC, but I prefer Hyper-V and recommend it highly. To get started with Hyper-V in case you are not familiar with this platform, see my Hyper-V tutorial on TenForums.com
Create and configure VM
Create a new VM. The VM generation can be whatever you’d prefer, Generation 1 or Generation 2. In the New Virtual Machine Wizard, assign enough RAM (2 GB minimum) and disable (unselect) dynamic memory. For the next step leave the connection status as Not connected for now. We will do our Windows Setup without a network connection and will instead connect later:
Accept the default 127 GB virtual hard disk size, and in the next step select ISO as the install media, then browse to and select your preferred Windows 10 ISO image:
Finish the wizard. Before starting the VM up, right-click it in Hyper-V Manager and select Settings. Increase the number of virtual processors, two will be enough in most cases, and disable (unselect) automatic checkpoints. Click OK to save your settings:
Start the VM, and install Windows normally. This VM will have quite a short life span, so it does not have to be activated. When Windows Setup asks for a product key, select I don’t have a product key and continue on with setup:
When OOBE starts and the region and language selection screen is shown, press and hold down both the CTRL and SHIFT keys, press the F3 key, then release all keys. This causes Windows to restart and boot into the so-called Audit Mode (a special customization mode for Windows):
Windows installation on our reference VM will take 10 minutes or more even on a relatively fast host (host = PC used to run Hyper-V or other virtual machines). On the laptop I am using at the moment, it takes about 20 minutes. This gives us time to prepare and collect assets such as software installers, wallpapers, additional files and so on.
Create a new folder on any network share you have at your disposal. Name it Assets (or whatever you like). In case you don’t have any network shares on your host, create a new folder anywhere, name it Assets and share it. Right click that new folder, select Properties, select the Sharing tab, click on Advanced sharing, select Share this folder, name it as you like, click OK to save it, and then click Close to close the folder properties window:
Nowadays, the first asset I always copy to the Assets folder is the OneDrive standalone installer (get it here). There’s a known bug in Windows 10 since version 1703 that renders OneDrive unable to run after Windows has been sysprepped. Thus, it needs to be reinstalled. When I start customizing Windows on any reference VM, I will uninstall OneDrive first and foremost. The, I set this offline installer to run automatically when the first user signs in after Windows has been installed from my custom ISO.
It’s up to you: if your users don’t need OneDrive, you don’t need to reinstall it. Personally, I can no longer even think how to cope without my several terabytes of OneDrive storage on multiple accounts. For me, therefore, the OneDrive standalone installer is the first asset to copy into the Assets folder.
There’s another minor bug in Sysprep. Since Anniversary Update version 1607, when Windows image gets sysprepped, end users see the built-in admin’s folders in File Explorer’s Quick Access. Ditto for the built-in admin’s recent files (everything we work with when customizing a Windows image). Fortunately, there’s an easy fix. On the host machine, open Notepad and copy these two lines into a new file:
echo Y | del %appdata%\microsoft\windows\recent\automaticdestinations\* del %0
Save this file as RunOnce.bat in the Assets folder. We will later add this file to our Default Profile (the base profile Windows uses for each new user profile). The first line resets Quick Access and Recent Files to Windows defaults when a new user signs in for the first time. The second line then deletes the batch file itself from this specific user to ensure that it will only be run the first time a new user signs in.
Next come the Windows theme files. Windows won’t get activated as we start customizing in Audit Mode. Thus, this disables all personalization options using the Settings app. However, there’s nothing to prevent applying an imported a so-called Windows Desktop Theme Pack file with long extension .deskthemepack. On your host, create themes as you wish (wallpapers, colors and so on), then right click the theme in Settings > Personalization > Themes and select Save for sharing, saving them to the Assets folder:
The unattend.xml answer file to automate OOBE we created in Part 3 of this series must go into the Assets folder, too. Also, if you have prepared an OEM logo image (120*120 bitmap), and you added an OEM logo location into unattend.xml answer file in Part 3, copy that oemlogo.bmp file now into the Assets folder.
The rest is up to you. You can download and install software directly onto the reference virtual machine when we start customizing. If you’d prefer using offline and standalone installers, you can download them onto the host while Windows is still installing on reference VM and copy them into the Assets folder. In addition, if you want user profile folders to contain any documents, images, videos and such when a new user account is created, copy all this stuff into the Assets folder, too.
In the following screenshot my sample Assets folder contains the all-important unattend.xml answer file (the key to everything), my OEM logo image and RunOnce batch file, standalone installers for Chrome, Firefox, and VLC Player, the OneDrive standalone installer and a few Windows theme files, like this:
Windows on our reference VM should have started in Audit Mode and signed you in using built-in admin credentials (no user accounts exist yet) by now. A visible telltale that we are indeed in Audit Mode is the Sysprep prompt shown on desktop. Close it for now by clicking Cancel:
VM is now using basic 1024*768 resolution. Change it to something more comfortable if you wish. I prefer to set my screen resolution to 1600*900 when customizing to give myself more workspace.
OK, now it’s time to connect to the network. In the VM, select File > Settings, select Network Adapter on the left pane, select Default Switch (or any other external switch) from the Virtual switch drop down list, and click OK to save settings:
The VM will now have network and Internet connections. Open File Explorer > This PC, map the host Assets folder as a network share entering a path to the share folder: \\HostComputerName\AssetsFolderShareName. Disable (unselect) Reconnect at sign-in, selelct Connect using different credentials, then click Finish:
A prompt will ask you to enter credentials. Enter your host machine admin account username and password, then click OK:
The host Assets folder now resides in File Explorer > This PC on the reference VM. Copy unattend.xml, RunOnce.bat, and the two optional files OneDrive installer and OEM logo to the following folders:
- unattend.xml to folder C:\Windows\System32\Sysprep
- RunOnce.bat to folder C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
- OneDriveSetup.exe to folder C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
- oemlogo.bmp to folder C:\Windows\System32
Notice that ProgramData and AppData are hidden folders, and are not shown in File Explorer by default.
Run your standalone installers, install all software you want to from the Internet. Do not run any of your installed apps, to avoid them creating user specific AppData folders. Apply desktop theme files, applying last the theme you want to be the default theme for each new user’s first sign-in (the current theme when we sysprep will be the system-wide default theme).
In my case I first uninstalled OneDrive (Settings > Apps > Microsoft OneDrive > Uninstall), installed Chrome. Firefox and VLC using the standalone installers in the Assets folder, applied all themes, with the last them as the one I want to be the default. I then installed Opera, Office 365 (2016) and some third party tools from the Internet. When all downloads were done, I deleted the contents of Downloads folder because everything left to built-in admin’s user folders now will be copied to default user profile when we sysprep Windows, and from there to any and all new user profiles. If you have any files you need to be present when Windows is installed from this custom image, copy them now to respective folders (Documents, Pictures and so on).
When all this is done, only one step is missing before we can sysprep the image — namely, Disk Clean-up. Open Command Prompt (no need to elevate, we are already using an elevated built-in admin account), and run the following command:
cmd.exe /c Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535
This opens the Advanced Disk Clean-up prompt. Select each and every item on the list, then click OK to start cleanup operations:
Let Disk Clean-up finish, then close the Command Prompt. Everything done, here’s my reference VM’s desktop, ready to be sysprepped (click to open enlarged in a new tab.):
We will sysprep Windows on reference VM, capture it to a WIM file and create a custom ISO based on it in the fifth and final part of this series. Stay tuned!
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.