Hi,@Kran2022. Welcome to Microsoft Q&A.
I tested the code you provided and it could successfully set the Windows RE status
of Recovery
to Enabled
.
The following is my additional successful test solution, you could try it.
First, make sure the reagentc /enable
command is available. You could try to start recovery
directly through the reagentc /enable
command in the command prompt
.(If the command is not available, you need to correct its environment variables)
Create a WPF program and add code.
MainWindow.xaml.cs
Create the EnableRecovery.bat
file and add it to the WPF project.
EnableRecovery.bat
@echo off
rem Check the current recovery status
echo Check the current recovery status...
reagentc /info
rem Enabling Windows Recovery Environment
echo Enabling Windows Recovery Environment..
reagentc /enable
rem Check the recovery status again to confirm it is enabled
echo Check the recovery status again to confirm it is enabled...
reagentc /info
echo Finish.
pause
Click EnableRecovery.bat
and set its properties.
Run the WPF program.
Enter the command reagentc /info
in the Command Prompt
, and you could see Windows RE status of Recovery : Enabled
.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.