Download Windows Recovery Environment (or any WIM image) from USB flash

  • Tutorial
Windows Recovery Environment

Boot into WinRE can be useful for quick repair of installed Windows: restoring a system startup, restoring from an image, rolling back to a restore point, changing boot parameters, and finally access to the command line, which means the ability to do many different interesting things, such as format C:.
In addition, you can run regedit.exe and other system programs, and even some third-party software, unless of course it does not require running “normal” Windows to work.
An alternative solution, of course, is to boot from the installation DVD or the ISO image, but launching the WIM image of the Recovery Environment directly will be faster - it weighs much less than an entire DVD.
In addition, on the same USB-stick you can place several WIM-images, for example, 2 WinRE images of different bit sizes (x32 + x64), and other images from the “repair” DVD. I have AntiWinLocker loaded in the same way , and this without having to have a separate ISO with it.
In general, the ability to download a WIM image can be very useful. So let's get down to business.

In fact, I personally create bootable flash drives based on GRUB4DOS, but today we will consider a less alternative way to get around only with standard Windows OS tools.

What is needed

1) the winre.wim image itself , which can be obtained in two ways:

- from the installed system, in Win7 it is located in C: \ Recovery \ recovery-guid (where the recovery-guid folder is a set of letters / numbers); in Win8 and higher - in C: \ Recovery \ WindowsRE .

Or the C: \ Recovery folder may not exist, then it is located on the special Windows boot partition “System Reserved”, which has a size of 100-500 MB and is located on the disk to the main system partition C: \ .
Then this small section needs to be assigned a letter in Disk Management.

More complicated case: \ Recovery folderIt is located on the hidden OEM recovery partition , which just doesn’t have to assign a letter, before that you need to change its type .
This is done using the Command line launched on behalf of the Administrator and DiskPart :

DISKPART> list disk
DISKPART> select disk 0
DISKPART> list partition
DISKPART> select partition 2
DISKPART> detail partition
DISKPART> set id = 07 override
DISKPART> assign

( disk 0and partition 2shown as an example, see the real numbers of the required drive / partition in the command output list; use it to detaillook and remember the partition ID before the change to return it back)

IMPORTANT: winre.wim copied from the recovery partition created by the manufacturer of the computer or laptop, may differ from the standard and may not have the necessary functions !
Therefore, it is better to take it

- from the installation DVD from the \ sources \ install.wim image - inside the image the file is located on the path \ System32 \ Recovery .

WIM images can be mounted on a system using DISM :

md C:\wim
rem в Win7:
dism /Mount-Wim /WimFile:C:\Recovery\recovery-guid\winre.wim /Index:1 /MountDir:C:\wim /ReadOnly
dism /Mount-Wim /WimFile:D:\sources\install.wim /Index:1 /MountDir:C:\wim /ReadOnly
dism /Unmount-Wim /MountDir:C:\wim /Discard
rem в Win8/8.1/10:
dism /Mount-Image /ImageFile:С:\Recovery\WindowsRE\winre.wim /Index:1 /MountDir:C:\wim /ReadOnly
dism /Mount-Image /ImageFile:D:\sources\install.wim /Index:1 /MountDir:C:\wim /ReadOnly
dism /Unmount-Image /MountDir:C:\wim /Discard

or open the latest version of 7-zip .

2) auxiliary file boot.sdi - also located inside winre.wim or install.wim along the path \ Windows \ Boot \ DVD \ PCAT , or on DVD in \ boot .

3) the program bootsect.exe in order to make the flash drive bootable - also look in WIM in \ Windows \ System32 , or on DVD in \ boot .

Formatting a flash drive

Usually this is not necessary, and flash drives, as a rule, already have one partition formatted in FAT32 (despite the fact that many manuals for creating bootable flash drives recommend formatting in NTFS, this is not necessary), which is active (bootable). Or maybe not. :-)
Therefore, if your flash drive is not loading, format it like this:

DISKPART> list disk
DISKPART> select disk 2
DISKPART> create partition primary
DISKPART> select partition 1
DISKPART> active
DISKPART> assign

( disk 2indicated as an example, see the real number of your flash drive in the previous command, otherwise you can format the hard drive; use format FS=NTFSif you like it more)

Create boot sector

bootsect /nt60 E:

(where E: is the letter under which the flash drive is mounted)

Install bootmgr bootloader

Again, there are 2 ways: using the installation DVD and without it.
1) First, consider the method only using the existing system:

bcdboot C:\Windows /l ru-ru /s E:

You must remember about the bit depth of the OS version!
If you are creating a flash drive with the x32 version of WinRE for treating x32 systems, then the source system, from where the bootloader is copied using bcdboot.exe, must be exactly x32. About x64, respectively, the same thing.
But the plus is that with this method you can have at least 10 WinRE versions on one USB flash drive - from all systems (Windows Vista / 7/8 / 8.1 / 10 + similar server versions) and any bit depth. At the same time. Without registration and SMS. :-)

2) If you use DVD, you need to copy the following folders and files (and of course, when copying manually, the Windows version is not important!):


(this is the minimum set of necessary files; they can also be manually copied from the system, from drive C: - WITHOUT using bcdboot.exe , which will copy more files)

A digression about different versions of Windows
It depends on which bootmgr file you take , which bootloader will be: text, with keyboard control, or graphic, with mouse support.
Win7 uses text mode, while Win8 / 8.1 / 10 uses graphical mode.
The text version, of course, loads faster.
The 3 font files above is the minimum set for the Russian language for bootmgr from Windows 7 , in addition, these files are optional - without them, the font will be simpler.
Newer versions of Windows use more font files.

I recommend using bootmgr from Windows 7, and the winre.wim image from Windows 10 , because recovery environment theoreticallyimproved from version to version.
Where to get the files: from the installed system or from DVD - it does not matter.

Create boot record

cd /d E:\boot
bcdedit /store bcd /copy {default} /d "Windows Recovery Environment"
bcdedit /store bcd /set {new-guid} device ramdisk=[boot]\boot\winre.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store bcd /set {new-guid} osdevice ramdisk=[boot]\boot\winre.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store bcd /set {new-guid} locale ru-RU

(where {new-guid} is the GUID of the new boot record, see the output of the first command)

After the sequential execution of all the commands, the boot record will be created, however its contents will be slightly different, depending on where the BCD storage file was taken from .
This is due to the fact that the basis for creating a new record is taken from different source records from the repository: to run the setup program, or to boot Windows.

A complete listing of a working boot record taken from a Windows 7 x32 DVD:

Загрузка Windows
идентификатор           {c53853d4-c6c5-11e5-af22-0018f368b2c9}
device                  ramdisk=[boot]\boot\winre.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
path                    \windows\system32\boot\winload.exe
description             Windows Recovery Environment
locale                  ru-RU
inherit                 {bootloadersettings}
osdevice                ramdisk=[boot]\boot\winre.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
systemroot              \windows
detecthal               Yes
winpe                   Yes
ems                     Yes

Based on this entry, you can create others in the same way, for example, to download winre.wim from the x64 version of Windows, just changing the path to the WIM files in the deviceand parameters osdevice.

Copy a WIM image

Copy the winre.wim and boot.sdi files to the \ boot folder on the USB flash drive.
The folder can be any (then adjust the paths in the bcdedit commands above), but both files must be in the same folder.
To boot multiple images, a single boot.sdi file is sufficient .

Download from flash drive

Do not forget to configure the BIOS to boot from USB, and after a while you will find yourself in the Windows recovery environment.

PS Commentators suggest that this method does not work on computers and tablets with UEFI.
But I can’t verify this (and can upgrade this instruction) due to the lack of a suitable device.

UPD 02.02.2016, 15:40:
Additions about extracting images from hidden partitions and mounting them in the system using DISM.

Also popular now: