Is there another way to get the last restore point's name in C# other than using powershell?
Here is the code I'm currently using:
private void Rp_MouseEnter(object sender, MouseEventArgs e)
{
try
{
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript("((Get-ComputerRestorePoint)[-1]).Description");
foreach (var o in PowerShellInstance.Invoke())
{
rp.ToolTip = o.ToString();
}
}
}
catch (Exception)
{
rp.ToolTip = "No previous Restore Points found";
}
}
The
((Get-ComputerRestorePoint)[-1]).Description
doesn't really work most of the times . I have tried it in powershell too and it only works when the Restore Point is freshly created, so I'm getting the exception's message most of the time since nothing is retrieved.
LE: Everyhing is run as admin. That's not the issue. The problem is that the command works after a restore point is freshly created, but after some time it fails to produce any output, even though you can find the created restore points using Get-ComputerRestorePoint