
Information
Most computers today with OEM pre-installed Windows come with a so called Factory recovery partition. This partition allows users to restore Windows 10 to it's original state, as it was when shipped from the factory.
Although a practical feature, restoring Windows to its original state from manufacturer recovery partition means just that, restoring PC to its original state with all OEM bloatware and all possible trial software, Windows being not updated and so on.
I prefer formatting OEM recovery partition and using that space to create my own instead. I setup a pre-installed Windows or clean install it, update fully, install software as I prefer and create user accounts, and before starting to use Windows I capture the Windows image to a custom install.wim file and use it in setting up my own custom "factory recovery" partition.
When restoring Windows from this custom recovery partition, Windows is updated (as it was when image was captured), containing all pre-installed software, user accounts and user data, device drivers, custom settings like themes and so on.
This tutorial will show how to create your own custom recovery partition. The method is easy and relatively fast.
Contents
Click links to jump to any part
Part One
Capture Windows image

Note
Please notice: steps 1.1 through 1.3 are not required if your Windows 10 is already fully updated, all software is installed, user accounts created and Windows customized as you want to have it.
1.1) Update Windows fully
1.2) Create user accounts and install software you want to be included in Windows recovery image
1.3) Customize Windows as you'd prefer, changing theme and other settings to your liking
1.4) When done, boot computer from Windows install media, When the Windows Setup region and keyboard selection screen is shown, press
SHIFT + F10 to open
Command Prompt:
1.5) Type
DISKPART (#1 in next screenshot) and hit
Enter to start the disk partitioning utility
1.6) When booting from Windows install media, drive letters might be different from what they are when booting normally. Enter the command
LIST VOL (#2) to check partition letters
1.7) We need to capture the Windows partition and save that captured
install.wim file on another partition (internal or external drive) or on a shared network folder. Check what temporary drive letter your Windows system partition has, in my case now it is
D: drive (#3). In case you are saving the captured image to another partition on the same PC, check its drive letter, too. In this example case I could have chosen drive
E: (#4) as the location to save the captured Windows image, but instead I will save captured image on a network share
1.8) Enter command
EXIT to quit
DISKPART (#5)
1.9) This step is optional, only required if you want to save captured image on a network share
In this example now, I want to store the captured image on a shared network folder on another computer. To do that, I need first to initialize networking services with the command
wpeinit (#6), then map the shared folder on that PC to a drive letter on the local computer.
Path to a network share is told as
\\server\share where
server is the name of the computer where shared drive or folder is located, and
share is the name that drive or folder is shared with. In my case I have shared a folder on computer
AGM-W10PRO03, named the share as
Storage, so the path is
\\AGM-W10PRO03\Storage.
For this example, I’ll map the shared network folder as drive
Z: using the following command, entering network credentials (username and password to
\\server) when prompted (#7):
net use Z: \\agm-w10pro03\storage
1.10) Now I can capture Windows to a custom WIM file with DISM. The switch
/imagefile: followed by a path and filename tells the DISM command where to save the captured Windows image, in my case now I want to save image as
install.wim on mapped network drive
Z:. Switch
/capturedir: followed by the drive letter, colon and backslash tells DISM which drive contains the Windows installation I want to capture, drive D: in this example case. Change these according to your needs.
The command to capture image (#8):
dism /capture-image /imagefile:Z:\install.wim /capturedir:D:\ /name:"Recovery" /description:"My Custom Recovery Image" /compress:maximum

(Click to enlarge.)

Note
EDIT:
Please notice that the DISM command in above screenshot is missing the /description:"My Custom Recovery Image" switch. Without it, the image will be captured OK, but it might not work when trying to use it for system recovery.
I very strongly recommend adding the /Description switch to your DISM command to avoid any issues when recovery image is needed.
1.10) When done, close Command Prompt, close Windows Setup region selection window. Windows will restart, let computer boot normally to Windows
Part Two
Prepare Recovery partition
2.1) Create a new partition on any internal HDD or SSD by shrinking an existing one (
tutorial) or using unallocated space, name it as
Recovery.
Partition size (my recommendation) should be the size of your custom captured
install.wim + 1 GB, rounded up to next full GB. For instance, if your custom install.wim is 6.2 GB, adding 1 GB makes 7.2 GB. Round it up to 8 GB (8,192 MB) for Recovery partition
2.2) Mount Windows 10 ISO (same version & build as the captured Windows image) as virtual DVD drive (right click ISO image, select Mount). Copy its content to your new Recovery drive
2.3) On your Recovery drive, browse to
Sources folder and delete
install.wim, or
install.esd file in case your ISO was made using Windows Media Creation Tool. Replace the deleted WIM or ESD file by copying your custom
install.wim to same folder
Part Three
Add Recovery partition to boot menu
3.1) Copy following batch code, paste it to a new
Notepad text file or any other text editor:
Code:
@ECHO OFF
TITLE Add Recovery to Windows boot menu
:SETLETTER
CLS
ECHO.
ECHO ###################################################
ECHO # #
ECHO # This batch file creates recovery environment #
ECHO # adding it to Windows boot menu. #
ECHO # #
ECHO ###################################################
ECHO.
SET /P DRIVELETTER= ^-- Please enter drive letter for your custom recovery partition (without colon):
IF NOT EXIST %DRIVELETTER%:\sources\boot.wim ECHO. & ECHO No valid Windows image found on given partition %DRIVELETTER% &ECHO. & PAUSE & GOTO :SETLETTER
ECHO.
bcdedit /create {ramdiskoptions} /d "Ramdisk"
bcdedit /set {ramdiskoptions} ramdisksdidevice partition=%DRIVELETTER%:
bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
for /f "tokens=2 delims={}" %%i in ('bcdedit.exe /create /d "Recovery" /application OSLOADER') do (set guid={%%i})
bcdedit /set %guid% device ramdisk=[%DRIVELETTER%:]\sources\boot.wim,{ramdiskoptions}
bcdedit /set %guid% path \windows\system32\winload.efi
bcdedit /set %guid% osdevice ramdisk=[%DRIVELETTER%:]\sources\boot.wim,{ramdiskoptions}
bcdedit /set %guid% systemroot \windows
bcdedit /set %guid% winpe yes
bcdedit /set %guid% detecthal yes
bcdedit /displayorder %guid% /addlast
pause
Alternatively, you can download the above batch file here:
Recovery.bat
Remember to
unblock the downloaded batch file before using it (
tutorial)!
3.2) The sample batch file is for
UEFI based machines with
GPT partitioned HDD / SSD. If your PC is a
BIOS based system with
MBR formatted disk, change
winload.efi in line 21 to
winload.exe.
The line in question for UEFI / GPT systems:
bcdedit /set %guid% path \windows\system32\winload.efi
Same line for BIOS / MBR systems:
bcdedit /set %guid% path \windows\system32\winload.exe
3.3) Save the file as a batch file with extension
.bat, for instance as
recovery.bat
3.4) Open an
elevated Command Prompt, run the batch giving full path. For instance, if you saved it as
recovery.bat in
Scripts folder on drive
E:, enter following command:
E:\Scripts\recovery.bat
3.5) The batch file will be run, ask you the drive letter to Recovery partition you created, and set up the recovery environment adding it to boot menu

(Click to enlarge.)
That's it! You have now Recovery option in boot menu. Selecting it, Windows Setup is run and you can clean install Windows 10, your custom image restoring it to the exact state it was when custom image was created. Everything will be there, from your custom desktop theme to user accounts and software already installed.

Tip
If your system disk crashes and no boot menu is shown, you can do recovery from your custom recovery partition by booting from Windows install media and running Windows Setup manually from recovery partition.
For instance, if your recovery partition has drive letter F:, start Command Prompt with SHIFT + F10 when Windows Setup shows the region selection screen, then enter following command:
F:\Setup.exe
Windows Setup will be run from your custom recovery partition.
Happy recovery 
Kari