How to Add Your Utility to Windows Recovery Environment
The Windows Recovery Environment (Windows RE) is a crucial tool for restoring your system after various failures. If you want to enhance the recovery process, you can integrate your custom utilities into Windows RE. This can be particularly useful for system administrators or those who regularly handle OS maintenance and repair. In this guide, I’ll walk you through the steps to achieve this.
Step 1: Prepare Your Utility
First, make sure your utility is compatible with Windows RE and can run in a minimalistic environment, which has limited functionality. Ideally, your tool should not rely on services unavailable in this environment and should be able to launch from the command line.
Additionally, pay attention to the size of the utility. Windows RE files often have size constraints, so large applications may not be suitable. Optimize your tool if necessary to ensure it can operate in a constrained environment.
Step 2: Extract the Windows RE Image
The next step is to extract the Windows RE image from your system. To do this, open Command Prompt with administrator privileges and run the following command:
reagentc /info
This command will show the path to the Windows RE image, typically located at C:\Recovery\WindowsRE\Winre.wim
. Copy the Winre.wim
image to a separate folder for editing to preserve the original version in case anything goes wrong.
Step 3: Mount the Winre.wim Image
Now, you’ll need to mount the Winre.wim
image to edit it. Use the DISM
tool to accomplish this. In the administrator Command Prompt, enter:
dism /mount-wim /wimfile:<path to Winre.wim> /index:1 /mountdir:<mount folder>
Replace <path to Winre.wim>
and <mount folder>
with the actual paths. After running the command, the image will be accessible in the specified folder.
Step 4: Add Your Utility
Copy your utility into the folder where the image is mounted. Ideally, place the file in the System32
folder for easy access from the command line. For example, if your utility is named mytool.exe
, copy it as follows:
copy mytool.exe <mount folder path>\Windows\System32\
Once copied, confirm that your utility is correctly displayed and functions when the image is mounted.
Step 5: Add the Utility to the Recovery Menu
To integrate the utility into the Windows RE menu, you’ll need to edit the winpeshl.ini
file, which controls which applications start in the recovery environment. Open (or create) this file in the System32
folder and add your utility’s startup command:
[LaunchApps] %SYSTEMDRIVE%\Windows\System32\mytool.exe
If other entries are already listed, simply add your utility on a new line. Now, your tool will load in Windows RE on startup.
Step 6: Save Changes and Unmount the Image
After making all necessary changes, save the image and unmount it. Enter the following command:
dism /unmount-wim /mountdir:<mount folder path> /commit
This command will save your edits to Winre.wim
and unmount the image.
Step 7: Activate the Modified Windows RE Image
Once editing is complete, set the updated image as the active Windows RE image. Run this command:
reagentc /setreimage /path <path to folder with Winre.wim>
Replace <path to folder with Winre.wim>
with the path to your modified image. Verify that everything is working correctly by using the command:
reagentc /enable