Category filter

Script to enable/disable Windows Recovery Environment on Windows devices

Windows Recovery Environment (WinRE) is a recovery environment designed to fix common causes of unbootable operating systems. It enables IT admins to perform troubleshoots when a Windows device encounters issues such as startup problems, driver issues or corrupted system files. For instance, in the event of accidental data loss or file system errors, IT admins can use WinRE to access and recover important files from the system’s hard drive. Or, if a system encounters issues during a Windows update, WinRE can be used to retract the update and resolve related errors.

Even though it is recommended to keep WinRE enabled, if the organization has implemented alternative recovery solutions, WinRE can be disabled. IT admins may also need to disable and enable the WinRE while repairing it.

In this document we will learn how to enable and disable WinRE using scripts. IT admins can use these scripts to remotely enable/disable WinRE on their Windows devices using Hexnode UEM’s Execute Custom Script action.

Disclaimer:


The sample scripts provided below are adapted from third-party open-source sites.

How to check the status of WinRE?

Execute this command to check if WinRE is currently enabled/disabled on the device. You can verify the output under the Action History tab of the corresponding device.

Output of script to check status of WinRE under Action History tab

How to enable WinRE?

Execute this command to enable WinRE on your Windows devices.

How to disable WinRE?

Execute this command to disable WinRE on your Windows devices.

Exception:


If this error “This command can only be executed from an elevated command prompt” prompts while executing the above-given scripts directly on the device end, it indicates you need administrator privileges to execute the scripts.

Execute the following command to open Command Prompt as an admin:

Then, execute the scripts given above.

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository