以编程方式创建系统还原点是“禁忌”吗?我会在执行软件更新之前执行此操作。如果有更好的方法可以仅使用我的软件文件和数据创建还原点,请告诉我。
我想要一种方法,如果在更新期间一切正常(关闭/终止更新应用程序、断电、用户拔掉插头等),我可以让用户恢复到已知的工作状态
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);
}