以編程方式創建系統還原點是否「禁忌」?在執行軟件更新之前,我會這樣做。如果有更好的方法只用我的軟件的文件和數據創建還原點,請告訴我。創建系統還原點 - 思考?
我希望通過這種方式,我可以讓用戶回到已知的工作狀態,如果在更新期間所有內容都會更新(關閉/關閉更新應用程序,關閉電源,拔出插頭等)
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);
}