我正在寻找一种通过按下按钮来创建具有当前日期和时间的系统还原点的方法。我已经尝试在网上搜索一个简单的方法来实现这个功能,但是我还没有找到合适的方法。
我在http://msdn.microsoft.com/en-us/library/windows/desktop/aa378847%28v=vs.85%29.aspx找到了这段代码片段,但它是用VB而不是C#编写的。我尝试将其转换为C#,但似乎并不是很成功。
我在http://msdn.microsoft.com/en-us/library/windows/desktop/aa378847%28v=vs.85%29.aspx找到了这段代码片段,但它是用VB而不是C#编写的。我尝试将其转换为C#,但似乎并不是很成功。
'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