I'm looking for a way to create a system restore point with the current date and time by pressing a button. I've tried searching the web for a simple way to do this but I haven't found one yet.
I found this code snippet from: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378847%28v=vs.85%29.aspx but it is in VB and not C#, I tried converting it a bit but I don't think i'm doing a great job of translating it.
'CreateRestorePoint Method of the SystemRestore Class
'Creates a restore point. Specifies the beginning and
'the ending of a set of changes so that System Restore
'can create a restore point.This method is the
'scriptable equivalent of the SRSetRestorePoint function.
Set Args = wscript.Arguments
If Args.Count() > 0 Then
RpName = Args.item(0)
Else
RpName = "Vbscript"
End If
Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
If (obj.CreateRestorePoint(RpName, 0, 100)) = 0 Then
wscript.Echo "Success"
Else
wscript.Echo "Failed"
End If
Here's a VB.NET snippet to create a restore point (found here):
Should be easy to "translate" to C#.
And here's another snippet in C# taken from this question: