Here's a VB.NET snippet to create a restore point (found here):
Dim restPoint = GetObject("winmgmts:\.
ootdefault:Systemrestore")
If restPoint IsNot Nothing Then
If restPoint.CreateRestorePoint("test restore point", 0, 100) = 0 Then
MsgBox("Restore Point created successfully")
Else
MsgBox("Could not create restore point!")
End If
End If
Should be easy to "translate" to C#.
And here's another snippet in C# taken from this question:
private void CreateRestorePoint(string description)
{
ManagementScope oScope = new ManagementScope("\\localhost\root\default");
ManagementPath oPath = new ManagementPath("SystemRestore");
ObjectGetOptions oGetOp = new ObjectGetOptions();
ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);
ManagementBaseObject oInParams =
oProcess.GetMethodParameters("CreateRestorePoint");
oInParams["Description"] = description;
oInParams["RestorePointType"] = 12; // MODIFY_SETTINGS
oInParams["EventType"] = 100;
ManagementBaseObject oOutParams =
oProcess.InvokeMethod("CreateRestorePoint", oInParams, null);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…