Question

I have 2 installers for 2 different applications, both of which also install a common support/diagnostic tool.

For the exe file I have added the sharedfile flag, so that when a user installs both applications and then uninstalls one of them, the diagnostic tool remains.

However, I also add a start-menu shortcut to the diagnostic tool, which gets deleted by the uninstaller.

How can I make the shortcut remain if one of the applications still exists, or if the diagnostic tool exe is still there, but delete if both applications are removed (or only one was installed in the first place)?

[files]
Source: "{app}_dynamic\SupportApp\*.*"; DestDir: "{app}\SupportApp"; Flags: sharedfile; Components: Support

[icons]
Name: "{group}\Tools\Send diagnostic logs"; Filename: "{app}\SupportApp\Support.exe"; Flags: uninsneveruninstall; Components: Support

[edit] Came up with this:

(initial work done by TLama: https://stackoverflow.com/a/12645836/2021217)

[code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
    if CurUninstallStep = usPostUninstall then
    begin
        if (not(FileExists(ExpandConstant('{app}') + '\SupportApp\Support.exe'))) then
        begin
            if (MsgBox('deleting "' + ExpandConstant('{group}') + '\Tools". "' + ExpandConstant('{app}') + '\SupportApp\Support.exe" doesnt exist', mbConfirmation, MB_YESNO) = IDYES) then
            begin
                DeleteFile('"' + ExpandConstant('{group}') + '\Tools\Send diagnostic logs"');

                DeleteFile('"' + ExpandConstant('{group}') + '\Tools\Send diagnostic logs.lnk"');

                RemoveDir('"' + ExpandConstant('{group}') + '\Tools"');
            end;
        end;
    end;
end;

It all seems to work, except for the deletion part...the deletefile and removedir function calls don't seem to work! Any help is appreciated

Was it helpful?

Solution

[code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
    if CurUninstallStep = usPostUninstall then
    begin
        if (not(FileExists(ExpandConstant('{app}\SupportApp\Support.exe')))) then
            DelTree(ExpandConstant('{group}\Tools'), True, True, True);
    end;
end;

Many Thanks to TLama for guiding me to a final solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top