Enable recovery using ReagentC using Csharp or bat file

Kran2022 406 Reputation points
2024-12-09T09:36:37.18+00:00

Hello All, Morning:

I would like to enable recovery using ReagentC in my windows LTSC 21H2 19044.5131 system using C# application so i set the app manifest by default launch ad admin.

I tried to launch the the batc file via this application but recovery is not set, if i launch the .bat file seperately the script works.

How can i launch the batch file from my app to eanble the recovery? do i need to tweak something in the registry?

Also another command prompt applciation but its not working. I have attached the codes in the notepad file : https://codefile.io/f/m11qxHjMZ1

Can somebody help with C# how to enable recovery? thanks in advance

Note:

Forum keep showing the below message evna resetting the browser history/cache etc..

Please fix the following issues to continue:

You are not authorized to make this response. If you believe this to be in error, please refresh the page and try again.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,652 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,804 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hongrui Yu-MSFT 3,645 Reputation points Microsoft Vendor
    2024-12-10T08:20:41.27+00:00

    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

    enter image description here

    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.

    Screenshot 2024-12-10 075714

    Run the WPF program.

    Enter the command reagentc /info in the Command Prompt, and you could see Windows RE status of Recovery : Enabled. Screenshot 2024-12-10 080806


    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.