1 Create a custom Windows 10 “factory recovery” partition – Win10.Guru
Go to ...

RSS Feed

Create a custom Windows 10 “factory recovery” partition

These days, most new computers with a pre-installed operating systems ship with a so called factory recovery option. This allows users to completely reset the computer by restoring an image stored on a specific factory recovery partition. The problem with factory recovery is that it restores everything the way the original equipment manufacturer (OEM) wants them. This might include a bunch of “bloatware”, useless software like “30-day trial of XYZ” or “Tweak your PC with this fabulous tweaker” and so forth. One of the first things any user wants to do when setting up a pre-installed Windows on a new computer is to get rid of all this bloatware.

In this post I will show you how to either replace the factory recovery partition with your own custom version, or to create one in case your computer does not have a factory recovery option and partition available to start with.

To begin, open This PC in File Explorer, right click the Windows partition C: and select Rename. Give the partition a distinctive name like “Windows 10“. It will help you later to identify the system partition. If you have no shared network folders on another PC available or alternatively no other partitions than Windows partition on this PC you are using to capture custom Windows image, create a new partition on any internal or external disk or share a folder on another PC on your network to store captured custom Windows image.

Customize your Windows exactly as you want it. When Windows 10 is working as you’d prefer, all required software installed, bloatware and unnecessary apps uninstalled, settings changed and user profiles created, boot computer from either a WinPE media or Windows 10 install media. When Windows Setup starts showing region and language selection, press SHIFT + F10 to open Command Prompt:

Click to open enlarged in a new tab.

Type DISKPART (#1 in next screenshot) and hit Enter to start the disk partitioning utility. When booting from PE or install media, drive letters might be different from what they are when booting normally. Enter the command list vol (#2) to check partition letters. 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.

Enter the command EXIT to quit DISKPART (#5).

In this example now, I want to store the captured image to a shared network folder named Storage on a another computer AGM-W10PRO03. 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. For this example, I’ll map the shared network folder as drive Z: using the following command (#7):

net use Z: \\agm-w10pro03\storage

When prompted, I will enter the network credentials (Windows username & password) for that 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 drive I: on computer AGM-W10PRO03 as Storage, so the path is \\AGM-W10PRO03\Storage. Change yours accordingly.

OK, everything is ready to capture the Windows install image. In this example, I am capturing the Windows system from drive D: on the local computer to the install.wim file, saving it on a shared network folder on another computer mapped as drive Z: (#8):

dism /capture-image /imagefile:Z:\install.wim /capturedir:D:\ /name:"Recovery" /compress:maximum

Capturing custom Windows image. Click to open enlarged in a new tab.

The switch named /imagefile: followed by a path and filename tells the DISM command where to save the captured Windows image. Switch /capturedir: followed by the drive letter, colon and backslash tells DISM which drive contains the Windows installation I want to capture.

When it’s done, close the Command Prompt and restart the computer booting back to Windows normally.

Check the size of your captured custom install.wim file. In my case it was just under 7 GB:

Create a new partition on any internal disk. Make that partition one GB bigger than your install.wim and name it Recovery. Notice that if you create this partition on the same disk where Windows is installed, and that disk gets corrupted, you will also lose the Recovery partition. Therefore I recommend that you create the custom recovery partition on another disk. However, assuming your system disk will not die, you can also create the Recovery partition on it and use it anytime you need to restore a “factory recovery” image of your own making.

Download the latest Windows 10 ISO image, any edition. Mount it as a virtual DVD (double click, or right click and select Mount), copy its contents to your new Recovery partition. Browse to the Sources folder on your new Recovery drive, and delete the install.esd or install.wim file (only one of these will be present). Copy the captured custom install.wim file to this folder to replace the ESD or WIM file you just deleted (Recovery drive, Sources folder).

Open Notepad or any other text editor and paste the following code to a new text file. For my example, the Recovery drive has drive letter F: (highlighted blue in below code sample), change all three instances of drive letter F: to whatever drive letter your new Recovery drive uses. Script is for GPT partitioned UEFI devices; If using a MBR partitioned BIOS based device, change line bcdedit /set %guid% path \windows\system32\winload.efi to bcdedit /set %guid% path \windows\system32\winload.exe:

bcdedit /create {ramdiskoptions} /d "Ramdisk"
bcdedit /set {ramdiskoptions} ramdisksdidevice partition=F:
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=[F:]\sources\boot.wim,{ramdiskoptions}
bcdedit /set %guid% path \windows\system32\winload.efi
bcdedit /set %guid% osdevice ramdisk=[F:]\sources\boot.wim,{ramdiskoptions}
bcdedit /set %guid% systemroot \windows
bcdedit /set %guid% winpe yes
bcdedit /set %guid% detecthal yes
bcdedit /displayorder %guid% /addlast

Please notice: lines 4 & 5 in the preceding code sample belong together but are shown as two text lines here because of word wrap. Line do (set ID={%%i}) is not its own command line, it belongs to and must be at the end of  the line preceding it. Here’s a screenshot:

Batch file in Windows Notepad. Click to open enlarged in a new tab.

Save the file as a Windows batch file with the extension .bat, and name the file as you wish. I named it  recovery.bat, saving it onto the desktop (folder C:\Users\Kari\Desktop).

Open an elevated Command Prompt, Enter the following command, replacing the path and filename with your actual values:


The batch file now creates a custom recovery environment and adds it to the Windows boot menu:

Running recovery.bat. Click to open enlarged in a new tab.

That’s it! Your Recovery partition is created and added to Windows boot menu:

When the Recovery boot option is selected, normal Windows Setup will be run and you can clean install your custom Windows from the newly created Recovery partition, with all settings, themes, installed software and applications, drivers and user profiles exactly as they were at the moment when you captured the custom image.

Notice that if the disk where Windows is installed gets corrupted, or if you replace the disk with the new one, the boot menu is not shown. In that case simply boot the PC from WinPE or install media, open Command Prompt and check drive letters with DISKPART as told above, then run Windows Setup from Recovery drive. For instance, if DISKPART shows your recovery partition as drive R: you can start restoring simply using this command: R:\Setup.exe.

In case you want to prepare for a total hard disk failure which forces you to replace all disks, or if you just want to be prepared for every scenario, you can also create a bootable USB flash drive from the contents of the new Recovery drive. This will give you a “recovery-on-stick” tool allowing a fast recovery using your custom recovery media simply by booting computer from USB flash drive and running Windows setup from it.



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.

7 Responses “Create a custom Windows 10 “factory recovery” partition”

  1. Raymond Pare
    August 25, 2018 at 16:46

    I have been looking for exactly these instructions since I updated my laptop to win 10 from Win 7. Thanks for the very clear and well explained text. I was a tech doing first line servicing for a departmental Vax 11-750 during the ’80s at Queens university Kingston so I was immediately interested by your Bio Kari. One interesting fact I noticed when I had finished was that my OS had upgraded to Win10 Pro from Win 10 home. I am not sure if this happened during this process or not. I haven’t tried the recovery yet but I have no doubt it will work as advertised. Thanks again Ray Pare.

  2. August 25, 2018 at 16:56

    Thanks Raymond!

    I have not a faintest idea why your edition was switched from HOME to PRO, I just must to admit it.

    Having said that, do you remember how “cool” it was to do Cobol and Fortran code for VAX, how “from the future” the VMS operating system was?

    I still think those years as best in my life. The feeling to be allowed to be in the front row to follow computing evolution was a fabulous feeling.

    When studying, I got a special permission to connect to uni’s VAX machine from home using my then “superfast” 1200 baud modem. I can remember it to end of times how cool I felt first time when the connection worked.

  3. August 25, 2018 at 17:03

    Dear Raymond:

    Indeed, thanks for your kind and insightful comments. Ditto to Kari! This discussion brings back some fond memories for me, too.

    The first system I managed while still in grad school in 1979 was a DEC PDP-11/70. I started working on a DEC 10 later in grad school. But I really got into VAXen at Schlumberger, where I ran a development team that built a well logging API environment to permit re-processing of log files after they were collected. My crowning achievement was to write a DEC CLI (Command Language Interface) program that let us create a custom User Interface for a FORTRAN application at runtime, by presenting the operator with a questionnaire at the outset of processing, and then using the responses to build a tailored UI for their particular processing needs on the spot. It was fun, and pretty advanced stuff for 1984/85 when we developed the package and its supplementary utilities. Those were good times.

    Thanks again for sharing your feedback and comments with us.
    Best wishes,

  4. Raymond Pare
    August 26, 2018 at 22:30

    Hi Ed and Kari, Just a follow up to my comment to say that I tested the Widows recovery partition and all is well. I also used the partition to make a bootable memory stick as suggested and that works also. I must have a lot of stuff on my laptop as the image file was 22Gb but that may be due to iTunes, you don’t need too many movies to make 22Gb.
    My first introduction to DEC was to a PDP5 at Queens in 1970; discrete components with Germanium transistors and 5K of core memory with a self modifying bootstrap that you keyed in with switches if it wasn’t retained in memory. Thanks for the walk down memory lane, though mine is not what it once was as evidenced by the fact I had forgotten about upgrading my laptop in 2017, I plead old age and Spinal Cord surgery.

  5. August 26, 2018 at 23:34

    Raymond, good to know your recovery media passed the test.

    About the size, this is up to each user. As I store all personal data in OneDrive, I clean up the computer of all kind user data before creating the recovery partition. Restoring it is so easy, just set up OneDrive.

    On the other hand, there’s nothing wrong to include your music, photos, videos and such in recovery media. Of course it makes the recovery process slower because recovery image will be bigger, but you will get a completely restored system without any further actions.

    According to an old Finnish proverb, one likes mother, the other prefers daughter. That describes this quite well: each user is different and prefers different approach.

  6. October 26, 2018 at 19:53

    Everyone is BS’ing and praising but no one tried it: its faulty and not working. thanks for nothing
    (check the false batch file commands for the bootloader entry)

  7. October 30, 2018 at 05:40

    It is tested, it works, there’s nothing wrong with boot menu entries shown. I am sorry that you were not able to follow the instructions.

Leave a Reply