Piggybacking the installer for the new component was straightforward, using the following instruction in the Run section of the InnoSetup script.
Filename: msiexec.exe;The process of uninstalling the new component along with the main product (or giving the user the opportunity to uninstall the component) was a bit more complicated. InnoSetup supports Pascal scripting for carrying out custom actions before, during, or after the install process - for example, adding custom wizard pages or installing certain files depending on runtime conditions. The script below asks the user if they want to uninstall ProductXYZ, then checks the registry for the UninstallString entry which is associated with the product code for the standalone component.
Parameters: /i {tmp}\ProductXYZSetup.msi;
StatusMsg: Installing ProductXYZ...;
Flags: postinstall
[Code]Using this method it is possible to seamlessly install and uninstall multiple related applications, without any interaction from the user.
procedure UninstallComponent();
var
ProductCode: String;
RegKey: String;
UninstallString: String;
ResultCode: Integer;
begin
ProductCode := '{1234-XXXX-1234-XXXX}';
RegKey := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + ProductCode;
if RegQueryStringValue(HKEY_LOCAL_MACHINE, RegKey, 'UninstallString',
UninstallString) then
begin
MsgBox('Uninstalling ProductXYZ...', mbInformation, MB_OK);
Exec('>', UninstallString, '', SW_SHOW, ewNoWait, ResultCode);
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then begin
if MsgBox('Do you want to uninstall the Product XYZ?',
mbConfirmation, MB_YESNO) = IDYES
then
begin
UninstallComponent();
end;
end;
end;
No comments:
Post a Comment