On 28/04/2021 4:15 am, Sebastian P.R. Gingter wrote:
> However, I seem to miss a possibility to provide a script for
> OnUninstall or Before/After Uninstall for that component (or file, for
> that matter).
>
> I thought about using the CurUninstallStepChanged procedure for that,
> but I need to know if that component or 3rd party driver was really
> installed by my setup, or if someone else installed that driver (then I
> should not remove it).
>
> So, is there a way I can't find to execute custom uninstall code per
> installed component, or how can I find out if a specific component needs
> to be uninstalled in the CurUninstallStepChanged method?
If you use [UninstallRun] (don't forget the RunOnceId!) then it will be
run if the component was ever installed. It just works.
Using CurUninstallStepChanged gives you a bit more control over the
process (in particular, the ability to interpret exit codes), but you're
a bit more on your own.
You can use IsComponentSelected to see if the component was selected in
the most recent install/upgrade (which will usually be the case when the
component is installed), but it is possible to trick it if they unticked
the component at some point (and hence failed to upgrade it). Otherwise
you'd have to check if a file or registry key unique to that component
is installed or not.