【发布时间】:2012-05-31 17:56:41
【问题描述】:
我正在寻找一种方法,通过按一个按钮来创建具有当前日期和时间的系统还原点。我试过在网上搜索一种简单的方法来做到这一点,但我还没有找到。
我从http://msdn.microsoft.com/en-us/library/windows/desktop/aa378847%28v=vs.85%29.aspx 找到了这段代码 sn-p,但它是在 VB 中而不是 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
【问题讨论】:
标签: c# windows backup restore-points