Hi Zhang Shangyi,
I have modified the
Backup script so that it can also be executed as
Deferred (in system context), in which case you have the possibility to specify the backup folder yourself.
When not using the TempFolder as the backup folder, the Backup Custom Action must be set as "Deferred with no impersonation" - otherwise it might fail in Vista when attempting to write to the designated backup folder. When the Backup Custom Action is executed as Deferred, data is passed to it via the "Action Data" field, in the following format:
The modified VBS file and sample project are attached below. Some notes regarding the example project:
1. I have used the folder "[CommonAppDataFolder][ProductName]" as the backup folder. This usually is "C:\Documents and Settings\All Users\Application Data\[ProductName]" on Win2000 and XP, or "C:\ProgramData\[ProductName]" on Vista. You can change it to whatever is appropriate in your case.
2. The path of the backup folder is saved in the registry under the key
HKLM\[Manufacturer]\[ProductName] (see the Registry page) such that it can be retrieved from there by a Search (named BACKUP_FOLDER - see the Search page). Another alternative is to pass the backup folder directly to the Restore Custom Action, similarly to how it is currently passed to the Backup Custom Action.
3. In the Custom Actions page, a "Property Set with Formatted" Custom Action is used to set the value of the BackupList Property (used by the Backup script).
4. Note how the Backup Custom Action has been configured. The backup folder as well as the backup list are specified through the "Action Data" field in the format specified above. Note that the same backup folder that is written to the registry must be used here also. Note also the Execution Condition and that the CA is set as "Deferred with no impersonation" as discussed above.
5. The Restore Custom Action is similarly set as "Deferred with no impersonation". Note the Execution Condition and the value of the "Action Data" field (which specifies the value of the CustomActionData Property):
Code: Select all
[BACKUP_FOLDER]|[BackupList]<>[RestoreLocationList]
By specifying the backup folder here directly ("[CommonAppDataFolder][ProductName]" instead of "[BACKUP_FOLDER]"), you can avoid writing the backup folder to the registry and then using a Search to retrieve it.
Hope this helps.
Regards,
Ionut