gpt4 book ai didi

system-restore - 创建系统还原点 - 想法?

转载 作者:行者123 更新时间:2023-12-04 23:11:40 29 4
gpt4 key购买 nike

以编程方式创建系统还原点是“禁忌”吗?我会在执行软件更新之前执行此操作。如果有更好的方法可以仅使用我的软件文件和数据创建还原点,请告诉我。

我想要一种方法,如果在更新期间一切都发生了故障(关闭/终止更新应用程序、断电、用户拔掉插头等),我可以让用户回到已知的工作状态

    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);
}

最佳答案

Is it "taboo" to programatically create system restore points?



不。这就是 API 存在的原因;这样您就可以对系统进行伪原子更新。

关于system-restore - 创建系统还原点 - 想法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32845/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com