システムの復元ポイントをプログラムで作成することは「タブー」ですか? ソフトウェアの更新を実行する前にこれを行います。ソフトウェアのファイルとデータだけで復元ポイントを作成するより良い方法があれば、お知らせください。
更新中にすべてが失敗した場合(更新アプリを閉じる/強制終了する、電源が切れる、ユーザーがプラグを抜くなど)、ユーザーを既知の動作状態に戻すことができる手段が欲しい.
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);
}