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

37 thoughts on “Create a custom Windows 10 “factory recovery” partition

  1. 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. 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. 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. 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. 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. 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. 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.

  8. Dear Kari,
    Many thanks for detailed instructions. We only have one issue which is when we try to use the Recovery option.
    1- Every time Windows 10 is restarted, it goes into the screen where it shows two tiles, first is to boot into windows10, the second is to boot into “Recovery” (Blue buttons).
    It would be nice to know how to not interrupt normal reboot with such options unless certain key is struck during the boot.

    2- When we choose “Recovery” during the boot options menu, it seems to start loading but when the progress bar at the bottom of screen finishes, it simply reboots back to the same boot options screen.

    However, if we choose the troubleshooting options and then “Command Prompt”, if we switch drives to the Recovery drive letter and run the SETUP.EXE from there, we can follow through with the recovery successfully.

    So any ideas about the above challenges?

    Your insight would greatly be appreciated.

    1. Tony, I must apologize for the delayed reply.

      1.) Press WIN + R to open Run prompt, type msconfig and hit Enter. Select boot tab and change the boot menu timeout from default 30 seconds to for instance 3 or 5 seconds. This will show the menu for just enough time to select Recovery when necessary. See screenshot:

      2.) I am sorry but I cannot think of anything that could cause it not working, especially as you say that launching recovery (Windows Setup) manually from Command Prompt works.

      Not much help, I am afraid.

  9. Hi, Terrific instructions just a couple of questions. I already have an existing factory recovery partition;
    1) how do i find which partition it is if it not obvious?
    2) can I use theses steps to over write the recovery partition.
    Thanks in advance

    1. 1.) Best option to check which partition is what is to use Disk Management (WIN + X, select Disk Management).
      2.) Yes. For instance, on this HP ProBook laptop I am using at the moment to reply to you, I formatted the original HP’s OEM Recovery partition and use it as my custom recovery partition. However, I recommend creating a full system image backup containing everything on system disk before proceeding, in case you for any reason need to restore the original OEM partition anytime in the future.

  10. Kari, in your latest post in response to majciceEddie your wrote:
    “Yes. For instance, on this HP ProBook laptop I am using at the moment to reply to you, I formatted the original HP’s OEM Recovery partition and use it as my custom recovery partition.”

    it would be much appreciated if you could elaborate on how you achieved that with existing non-commercial tools from MS or open source.

    1. A good question. As the reply would be simply too long, I decided to write a new post about how I setup new machines which come with preinstalled Windows. Give me a couple of hours, I’ll post a link here when the post is ready.

      1. Tony, I am sorry but it’s 7 AM here, I need to sleep a bit before writing that post. I was somewhat distracted when replying to you earlier. The ice-hockey World Junior Championships 2019 ( have been going on in Victoria and Vancouver, British Columbia. Your comment was posted and I replied to it in middle of second period of the final, gold medal game, my native Finland playing against USA. My plan was to write the post after the game, but as we won (Yes! Finland is World Champion), I just continued watching the after game show on Finnish television. The problem is, British Columbia time is 9 hours behind my local time, game ending and after game show starting at 4:30 AM my time.

        Long story short: I’ve got some single malt to celebrate, was flying beyond our galaxy in my dreams. It’s past 7 AM. I’ll sleep first, write the post when back on earth 🙂

  11. If ran through the above article and figured it out. Just like to know if there is a way to incorporate future updates for my computer into the recovery image without going through the whole process again. Is that doable? If so, how?

    1. Anyway, as promised I wrote this today about how I setup pre-installed Windows:

      About updating the custom recovery partition, it can be done the same way as when updating your USB install media. I’ve written a tutorial about the process on TenForums:

      Official Microsoft support article:

  12. Just refreshed after posting my note about the game win, and noticed you had already posted the answer. You are FAST Kari… I am guessing the speed is why the finish team won 🙂

    One last question, if I were to have a programmer create a Wizard (GUI) to perform the entire process you have detailed above for “capturing a custom image, creating a new partition on the same drive as the O/S, copying all the required files, and setting it as the custom recovery partition”, what would be the best language to have it written in?

    I am hoping to create a program (non-commercial) to have a non-techy staffer perform the custom image process, then use the new recovery option during the boot to re-image the machine in future if need be. We have a number of laptops that would need to be re-imaged often.

  13. Successfully created the recovery partition with following your procedure. But I’d like to know since I’m using a windows tablet, I cant use the touchscreen after entering recovery partition. Is there any way to enable it?
    Another question how to relate that created recovery partition with existing recovery created by windows CD? So that when I refresh the windows with deleting all user data, I could get my driver installed

  14. Hey! I messed up the batch file portion i believe. System keeps booting to the recovery/install partion with no “choose which operating system”.. Main os is on C and recovery is on D

    1. Apparently you have not read the post, or you did not understand it.

      What you call “more refined” method is nothing else than a normal clean install. When used to recover Windows, it wipes the existing Windows installation, and performs a normal clean install, user losing all installed software, personal data and settings. I do not need a recovery partition for that, I can always clean install from USB flash drive.

      Quoting you, the “needlessly more complex” method told in this post keeps everything intact. All user accounts, their personal data and settings, as well as installed software will be captured to recovery image, and restored when Windows Setup is run from recovery partition. Honestly, this is more “refined” method. In addition, no registration for a third party tool is required, no third party tools needed at all.

      Nothing personal, just expressing my personal opinion: I find it quite weird that for you a standard clean install of Windows is more “refined” option than restoring / recovering everything.

  15. Hi Kari,

    Fantastic guide! Just what I needed.

    Would you mind elaborating the final paragraph a bit more on how to make a “recovery-on-stick” version of the recovery partition?

    I used a USB external drive as my “recovery partition”, but unsure how to make it a bootable option for more flexibility 🙂

    1. Usually, the custom install.wim is bigger than 4 GB, so it makes usual methods to create Windows 10 USB install media impossible due ridiculous FAT32 file system 4 GB file size limit.

      My way to do custom W10 USB flash drive install media with large WIM file:

      1.) Mount a Windows 10 ISO, and using it, create a USB install media as told in this post:
      2.) When done, replace the original install.wim in Sources folder on NTFS partition with your custom install.wim

      On my own network, I use Microsoft Deployment Toolkit to deploy (install) Windows to all physical and virtual machines. A nice feature in MDT is that I can use my custom WIM as operating system to be deployed. I simply import the custom WIM file to MDT, and deploy it to a target device. Nice and easy!

  16. I Fixed the problem when you delete disk Letter. it was pretty big challage for me but after browsing some microsoft docs and some try and errors I made it.

    1. Delete disk Letter from your recovery disk partition in disk manager or in CMD with diskpart command CMD use command diskpart
    3. list disk < here you find your disk, I used size to find what disk i want, it is size of whole disk, hardware
    4. select disk 0 <or any number what has your disk
    5. list partition < here you will see all partitions/volumes again, find your Recovery disk here
    6. select partition 1 < number of recovery disk partition.
    7. partition detail <here you can see if it is your recovery disk + all its details
    8. here we need to check/ change values at type what is partition ID and attrib what is Attribute
    when you have selected your recovery partition just type or copy this:
    SET ID=de94bba4-06d1-4d40-a16a-bfd50179d6ac <this is Ms recovery partition ID
    GPT ATTRIBUTES=0X0000000000000001 <this will allow to have disk without Letter in windows but
    it will get letter during instalation in recovery environment

    I did this in CMD from recovery environment, but probably you can do it in windows as CMD with admin rights

    I am pretty proud of myself 😀 I am total newbie in this but I am looking forward to make my career as Cisco network engineer

  17. Hi Kari

    I have followed your example above. I have it working through MDT2013 to automatically capture a WIM file and store it on a Recovery partition, R:\.
    The only problem I have, is when I run the recovery and restore the WIM file, it creates another entry in the BCD. This happens every time I restore the WIM file. At the moment I have:

    Windows 10 on volume 3
    Windows 10 on volume 3
    Windows 10 on volume 3

    All as the boot options as I have restored twice, once formatting the c: drive and the other time just reinstalling the wim file over the C: drive (this created a windows.old folder)
    All 3 windows 10 options will boot to the restored wim and Windows loads up with no problems.

    Any ideas

  18. Hi Kari

    Is there a way to make unauthorized access to recovery process impossible or at least difficult?

    I plan to keep the recovery partition on board of my laptop. Since my Windows installation already carries some of my personal data and credentials, I would love to either encrypt the .wim image or the whole recovery partition, or at least set a password prompt at the start of recovery process.

    Can this be done?

  19. Hi Kari,

    Thanks for the great instructions. However, I ran into a snag. My OS is an upgrade from Win7 to Win10Pro. I just tried your instructions and i get “This app can’t run on your PC”. My PC is MBR and I am using a partition on the same physical drive, the same way a factory recovery would be. I just had to rebuild my PC from scratch due to crash so it is Win10 Pro 1909 with all patches. I downloaded the Win10 ISO 1909. Below is my script. Thanks in advance.

    TITLE Add Recovery to Windows boot menu
    ECHO ###################################################
    ECHO # #
    ECHO # This batch file creates recovery environment #
    ECHO # adding it to Windows boot menu. #
    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
    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 (‘winload.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.exe
    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

  20. I used to mistakenly delete recovery partition in my harddrive to expand my data partition with Easeus.
    After i delete that partition to recover, i found 3 partition from end of disk: 1GB “Recovery” partition, 19GB “Windows system” like partition with Recovery folder in there, and 300MB FAT32 partition with EFI folder in it.

    After restarted, my system fail too boot, there are two boot option. And after i choose the other one, it can boot normally. But when i try to use “recovery” menu, it fail because something …file not found ( i forgot).

    1. How to fix Recovery command in Windows as it should be? Can you explain what is the “other” windows system found there ? Is it the “OEM” partition. Is this partition needed to Recovery ?

    2. What is differences WinRE.wim (439MB) on Recovery folder in “the other windows system” found later with winre.wim (381) on Recovery partition? I guess the last one created when installing active windows. Is both files can use for recovery ?

    3. If i compare Reagent.xml in recovery/winre folder of both partition, there are differences in 2 line, like

    How make these files useful again, or how to those make both of recovery files “alive” again to recover the system ?

    4. How to delete a boot option which direct to “dead” link ?

  21. I am not that techie and unfortunately deleted my Recovery Drive. Please guide me on getting it back. Now I am unable to format my system. I am on HP Spectre Notebook.

  22. Is there any way to add the f11 press key to enter in recovery?
    I’ve just started messing around with recovery partition on my laptop and i’ve updated my install. Wim from win8 to my custom install of win10, and the original partition has some power recover from cyberlink winpe(or what ever it’s called the tool that boots to when i press f11) and i was wondering if i can bring that stuff from my laptop to my pc and make my own recovery on pc too, but, i have no clue how to create the damn boot for it and most important how to make f11 key work and not using the boot screen to pop up every time when i power up my pc
    Has anyone some ideas?

    Any tutorial to edit bcd and add the wim to that power recover tool(win file) to be bootable via f11 would be much apreciated, the rest i can handle by myself(creating the install.wim file and so on)

    What makes f11 key to change the boot order?
    It will boot via this tutorial with f11 key?
    Thank you

  23. This doesn’t show me how to have a 500ish MB recovery partition that has no drive letter just like the OEM recovery partitions are. Really all I want to do is add the devices drivers so when the recovery happens all the drivers will be installed.

  24. I followed this excatly, and set the recovery to the same drive in another partition. I pasted in the text for the bat file, changed the drive letter, and used the exe for MBR since my drive is setup for MBR. Now when I restart my system boots into the recovery partition without asking. I don’t know how to change it back. It would be nice if I could press f3 on a reboot to bring up the boot partition selection.

Comments are closed.

More Stories From Deployment