Knowledge Base Glossary       Exit
(how to) Search  

Browse by Category
Knowledge Base > Operating Systems > Windows > Vista/Win7/8.x/10 > Repairing the Windows Recovery Environment (WinRE)

Repairing the Windows Recovery Environment (WinRE)

Problem:

The Windows Recovery Environment (WinRE) for Windows 7, Windows 8, or Windows 10 does not function correctly. The system is unable to boot into WinRE.

Additionally, the TBWinRE script is unable to modify WinRE on the system and may be unable to create the TBWinRE boot media.

Cause:

There are a number of reasons WinRE is unable to function, including:

  • WinRE is disabled.
  • The BCD file is not configured correctly to boot WinRE.
  • The winre.wim file is missing or not at the expected location.
  • The WinRE configuration file is missing or contains invalid information.

Solution:

Use the following methods to attempt a repair of WinRE. You may wish to read through all the methods before beginning as some may not be applicable to your situation or you may need to try them in a different order.

Note: Repairing WinRE will require using an Administrator Command Prompt. Reference the instructions below as necessary.

If using Windows 7: Click on the Start button, then All Programs, then Accessories (alternatively, press the Windows Key and type Command Prompt). Right-click on the Command Prompt item and select Run as administrator from the pop-up menu. If a UAC prompt is displayed, click the Yes button.

If using Windows 8.x/10: Press the Windows Key to display the Start screen and then type Command Prompt. The program should show in the search results. Right-click on the Command Prompt item and click Run as administrator. If a UAC prompt is displayed, click the Yes button.

Alternatively, in Windows 8.x/10 you can press WinKey+X to display the Quick Link menu. Select Command Prompt (Admin) and click Yes on the UAC prompt (if displayed).

Unable to Build TBWinRE Boot Media

If WinRE is broken, but you have the correct Winre.wim file for the system and you only want to build the TBWinRE boot media, it's not necessary to repair WinRE. Instead, you can just copy the Winre.wim file into the WinRE_Backup folder of the TBWinRE folder (e.g. D:\TBWinRE\WinRE_Backup). Be sure to use a version of the Winre.wim file that's compatible with your version of Windows.

Disable & Enable WinRE

Sometimes all that's needed is to disable WinRE prior to enabling. Run the following commands from an Administrator Command Prompt:
reagentc /disable
reagentc /enable

Note: It's possible for the disable to report an error and still have enable succeed.

Correct Invalid BCD File WinRE Reference

Verify the BCD entries for WinRE are correct.

Note: Successfully enabling WinRE using reagentc should automatically fix the BCD entries. However, this method is helpful when just the recoverysequence item's value is incorrect. Performing an automated boot repair using the Windows Startup Repair program can sometimes cause this type of problem.

  1. Open an Administrator Command Prompt.

  2. Run the following command to display the BCD entries:
    bcdedit /enum all

  3. Scroll through the entries and find the one for the currently booted Windows system. It will be a Windows Boot Loader entry with the identifier set to {current}. For example:

    Windows Boot Loader
    -------------------
    identifier         {current}
    device             partition=C:
    path               \Windows\system32\winload.exe
    description        Windows 7
    locale             en-US
    inherit            {bootloadersettings}
    recoverysequence   {d1758ad0-da09-11de-87b2-fe21320b6b8c}
    recoveryenabled    Yes
    osdevice           partition=C:
    systemroot         \Windows
    resumeobject       {d1758ace-da09-11de-87b2-fe21320b6b8c}
    nx                 OptIn


  4. Note the GUID value for the recoverysequence item. In this example, the GUID is {d1758ad0-da09-11de-87b2-fe21320b6b8c}.

  5. Next, look through the entries for a Windows Boot Loader entry with an identifier that's set to the GUID value. The description should be Windows Recovery Environment. An example is shown below. Note that several lines will wrap in the output (e.g. device and osdevice) and several additional lines are wrapped by this article's formatting.

    Windows Boot Loader
    -------------------
    identifier         {d1758ad0-da09-11de-87b2-fe21320b6b8c}
    device             ramdisk=[C:]\Recovery\d1758ad0-da09-
    11de-87b2-fe21320b6b
    8c\Winre.wim,{d1758ad1-da09-11de-87b2-fe21320b6b8c}
    path               \windows\system32\winload.exe

    description        Windows Recovery Environment
    inherit            {bootloadersettings}
    osdevice           ramdisk=[C:]\Recovery\d1758ad0-da09-
    11de-87b2-fe21320b6b
    8c\Winre.wim,{d1758ad1-da09-11de-87b2-fe21320b6b8c}
    systemroot         \windows
    nx                 OptIn
    winpe              Yes


    If not found, look for another Windows Recovery Environment entry (will have a different GUID) with Winre.wim at the correct location (the device and osdevice items show the path for the Winre.wim file). The location can be a drive letter (as in the above example) or a volume reference (e.g. [\Device\HarddiskVolume3]). If the correct entry is found it can be linked to the Windows entry by running the following command (make sure to use the GUID of the found entry). Command should all be on one line.
    bcdedit /set {current} recoverysequence {d1758ad1-da09-
    11de-87b2-fe21320b6b8c}

Note: If you have a multi-boot configuration using the Microsoft Boot Manager be aware that each Windows 7/8.x/10 boot entry will have its own Windows Recovery Environment entry.

Place Winre.wim at the Correct Location

Make sure the Winre.wim file exists in the expected path (e.g. on the existing Recovery partition) or in the C:\Windows\System32\Recovery folder. Note that both the folder and the file may be hidden (enable viewing of hidden/system files, if necessary).

You can determine if the original path is still being used by viewing the ReAgent.xml file and checking the path for the ImageLocation. The ReAgent.xml file is located in the C:\Windows\System32\Recovery folder and can be opened using Internet Explorer, Notepad, or WordPad. If using Notepad you will most likely want to enable word wrapping for easier viewing. Look for <ImageLocation path= and note the path value specified (e.g. <ImageLocation path="\Recovery\WindowsRE"). If the original Recovery partition is no longer available you can create the path on the Windows partition and copy the Winre.wim file into it. In this example, you would copy Winre.wim into the C:\Recovery\WindowsRE folder. Then try enabling WinRE by running the following commands from an Administrator Command Prompt:
reagentc /disable
reagentc /enable

Reset the ReAgent.xml File

If none of the above methods worked you can try resetting sections of the ReAgent.xml file (make a backup copy of the file first, if you wish).

Note: On Windows 8.x/10 systems you can try removing the ReAgent.xml file instead of editing it. It should be recreated when you run the command to enable WinRE. For example, you could rename ReAgent.xml to ReAgent_backup.xml before trying to enable WinRE.

This example will use WordPad to edit the file (using Notepad is not recommended since line breaks won't be displayed). Be aware that long lines will wrap -- do not add any new line breaks. Start an Administrator Command prompt and run the following command:
write c:\windows\system32\reagent.xml

Edit these sections to clear/reset the values: WinreBCD, WinreLocation, ImageLocation, InstallState, WinREStaged. Leave other sections and settings unchanged. The example below is from an OEM Windows 8 installation (your file contents may be different). The indicated sections are shown with cleared/reset values.

<?xml version='1.0' encoding='utf-8'?>
<WindowsRE version="1.0">

  <WinreBCD id="{00000000-0000-0000-0000-000000000000}"/>
  <WinreLocation path="" id="0" offset="0" guid="{00000000-0000-0000-0000-000000000000}"/>
  <ImageLocation path="" id="0" offset="0" guid="{00000000-0000-0000-0000-000000000000}"/>

  <OsInstallLocation path="\OKRbackup\factory\" id="0" offset="728680628224" guid="{f0ea3b1a-8657-4f56-abd1-dfea687a2d2f}" index="1"/>
  <CustomImageLocation path="" id="0" offset="0" guid="{00000000-0000-0000-0000-000000000000}" index="0"/>

  <InstallState state="0"/>
  <OsInstallAvailable state="1"/>
  <CustomImageAvailable state="0"/>
  <IsAutoRepairOn state="0"/>

  <WinREStaged state="0"/>
  <OperationParam path=""/>
  <OsBuildVersion path="9200.16384.amd64fre.win8_rtm.120725-1247"/>
  <OemTool state="1"/>
  <BootKey state="0"/>
  <IsServer state="0"/>
  <ScheduledOperation state="4"/>
</WindowsRE>


Save the file and close WordPad.

Make sure the Winre.wim file is in the C:\Windows\System32\Recovery folder. Then try enabling WinRE by running the following command:
reagentc /enable

Find & Restore the Winre.wim File

If the Winre.wim file is missing on your system you can try one of the following methods to locate it:

  • Search the system for the file. From an Administrator Command Prompt, run the following command to search a drive for the Winre.wim file:
    dir /a /s c:\winre.wim

    The above will search the C: drive for the file, including sub-folders and hidden folders. Depending on the system there may be multiple copies of the file found or there may be none.

    Many systems are configured with WinRE on a separate partition that is not normally assigned a drive letter. In order to search these partitions you would need to use Disk Management to assign a drive letter (may not be possible, in all cases).

    Note: If you previously had or currently have a version of Rollback Rx installed, the Winre.wim file may have been renamed to Winre.dat. If that's the case, run the search for it instead and rename it when you copy it for WinRE (or TBWinRE) to use. For example:
    dir /a /s c:\winre.dat
           
    Be aware that the winre.wim file often has the hidden and system attributes set. You can remove these using the attrib command or copy the file with the xcopy command and keep them intact. For example:

    attrib -h -s c:\Recovery\WindowsRE\winre.wim

    xcopy /h c:\Recovery\WindowsRE\winre.wim c:\Windows\System32\Recovery

  • If the system previously had a functioning WinRE and you have a backup image from that time you may be able to recover the file from your backup. For example, if you have a backup of the Windows 8 Recovery partition before it was deleted, use TBIView or TBIMount to access the backup and copy the Winre.wim file out. Keep in mind that it may be located in a hidden folder and the file itself may be hidden (these files/folders will show up normally in TBIView).

  • Locate the Winre.wim file on another system using the same version and architecture of Windows and copy it to the broken system. For example, if your desktop system running Windows 7 x64 is missing the file you could copy it from your laptop running Windows 7 x64.

  • If you have a standard Windows installation DVD or USB flash drive that contains the Install.wim file (not Install.esd) you can mount it and copy out the Winre.wim file. The Install.wim file will normally be located in the sources folder on the boot media.

    • Create a new folder to use as the mount point. The folder must exist on an NTFS partition and it must be empty. In this example, E:\Win7-Install will be used.

    • Open an Administrator Command Prompt.

    • Determine the correct index to use by running the following command (specify the correct drive letter and path to Install.wim for your system):
      dism /get-wiminfo /wimfile:"D:\sources\install.wim"

      Examine the output to find the index of the Windows installation. In the case of multiple versions (Home, Pro, etc.) you can just select one of them. Index 2 is used in this example.

    • Mount the Install.wim file to the mount point. Command should all be on one line.
      dism /Mount-Wim /WimFile:"D:\sources\install.wim"
      /index:2 /MountDir:"E:\Win7-Install" /readonly


      The mount may take several minutes to complete.

    • Browse to the E:\Win7-Install\Windows\System32\Recovery folder and copy out the Winre.wim file.

    • Unmount the Install.wim file. Command should all be on one line.
      dism /unmount-wim
      /mountdir:"E:\Win7-Install" /discard


  • Windows 10 only: If you have installation boot media or downloaded upgrade files that contain the Install.esd file you can extract the contents and copy out the Winre.wim file. This file will normally be located in the sources folder (may be a sub-folder such as \x64\sources) on the boot media. Note that it's recommended to have at least 15GB of free space available on the drive where you extract the file (extracted files can be deleted once you've obtained the Winre.wim file). If necessary, the Windows 10 Media Creation Tool can be downloaded from Microsoft.

    • Create a new folder to contain the extracted files. The folder should be on an NTFS partition and it must be empty. In this example, E:\Win10-Extract will be used.

    • Open an Administrator Command Prompt.

      Note: When running the Dism commands, if Dism has errors or problems working with the Install.esd file you may need to rename it to Install.wim. If the file is on read-only media this will require copying it to a new location first.

    • Determine the correct index to use by running the following command (specify the correct drive letter and path to Install.esd for your system):
      dism /get-wiminfo /wimfile:"D:\sources\install.esd"

      Examine the output to find the index of the Windows installation. In the case of multiple versions (Home, Pro, etc.) you can just select one of them. Index 1 is used in this example.

    • Extract the Install.esd file contents to the folder you created. Command should all be on one line.
      dism /apply-image /imagefile:"D:\sources\install.esd"
      /index:1 /applydir:"E:\Win10-Extract"


      This process will take a little while to complete.

    • Browse to the E:\Win10-Extract\Windows\System32\Recovery folder and copy out the Winre.wim file.

    • You can now delete the E:\Win10-Extract folder to free up the space. This can be done from the prompt or in Explorer. To delete it from the Command Prompt run:
      rd /s "E:\Win10-Extract"

      Important: Make sure you specify the correct folder path to delete.

Note: Regardless of the method used to find Winre.wim, you should make sure to use a version of the file compatible with the version and architecture of Windows for which WinRE is being repaired. For example, if you are repairing WinRE on a Windows 8 64-bit system you should use the Windows 8 64-bit Winre.wim file.


How helpful was this article to you?


powered by Lore