@Kran2022, Welcome to Microsoft Q&A, you could try to use Process.StandardOutput to check if the reagentc is disable.
internal class Program
{
static void Main(string[] args)
{
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "C:\\Windows\\System32\\ReAgentc.exe",
Arguments = "/info",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadLine();
// do something with line
if(line.Contains("Windows RE status"))
{
if(line.Contains("Disabled"))
{
Process newp = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "C:\\Windows\\System32\\ReAgentc.exe",
Arguments = "/enable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = false
}
};
newp.Start();
}
}
}
Console.ReadKey();
}
}
Tested result:
Hope my code could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and 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.