Hi,
For this example we will consider the "Test Key" registry key which contains the string value "Test". Also, in the "Registry" page of your Advanced Installer project you must add the new value of the "Test" entry (create the "Test Key" and "Test" entries under HKEY_LOCAL_MACHINE\Software).
Here is an example for the backup custom action:
Code: Select all
Function backup
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Test Key"
strValueName = "Test"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SOFTWARE\Test Key backup"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "Test backup"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
End Function
This custom action can be scheduled under the "RegisterMIMEInfo" standard action (right before the registry entries are created).
The restore custom action looks like this:
Code: Select all
Function restore
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Test Key backup"
strValueName = "Test backup"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SOFTWARE\Test Key"
strValueName = "Test"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SOFTWARE\Test Key backup"
oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
End Function
This custom action can be scheduled under the "Commit" standard action. Note that for this custom action you must use the condition
REMOVE = "ALL" in order to make sure that it is executed only during the uninstall.
Also, you need to make sure that the registry entry is not removed at uninstall (it is replaced by the old value). For this you go to the "Organization" page and set the "Permanent" attribute for the component of the "Test" registry value.
Note that if you use DWORD values then you replace
strValue with
dwValue in the scripts.
You can modify these scripts for the registry entry you need.
Regards,
Cosmin