[英]How do I create a system restore point everytime my installer is run?
默認情況下,MSI 會為安裝和卸載創建系統還原點。 每次運行我的安裝程序時,我必須做什么才能創建系統還原點,無論是安裝、修復、刪除、升級等?
好吧,升級是新產品的全新安裝,假設您的意思是重大升級,因此您不必擔心,因為安裝會在開始時創建一個。
假設用戶仍然擁有安裝源並可以訪問任何更新,卸載通常不是問題,因為他們只需重新安裝產品即可。
無論哪種方式,您都需要使用還原點 API 對其進行編碼,從以下開始:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa378727(v=vs.85).aspx
我不知道它是否適用於自定義操作。 如果沒有,那么您需要將這些操作包裝在創建還原點然后運行 MSI 的可執行文件中。
如果用戶關閉了系統還原,那么顯然這些都不會起作用。
這是您可以使用的功能
function CreateRestorePoint(sDescription: String): Boolean;
var
ScriptControl: Variant;
oWMI: Variant;
ErrCode: Integer;
begin
try
// Create the ScriptControl object.
ScriptControl := CreateOleObject('ScriptControl');
// Set the Language property (VBScript or JavaScript)
ScriptControl.Language := 'VBScript';
// Now create the WMI object we could not with straight Pascal code.
oWMI := ScriptControl.Eval('GetObject("winmgmts:\\.\root\default:Systemrestore")');
WizardForm.StatusLabel.Caption := 'Creating restore point...';
// Create the restore point.
ErrCode := oWMI.CreateRestorePoint(sDescription, 0, 100);
// Return the error code, if any. A value of zero indicates success.
Result := (ErrCode = 0);
except
Result := false;
end;
end;
在此處查找更多詳細信息https://github.com/matlo/GIMX-build/blob/master/windows/inno.iss
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.