0
votes

I have written a wix script for my application and it has 2 deferred custom actions associated with it.

One of the custom actions is run during installation and the other is run during uninstallation.

The error occurs during uninstallation if the uninstaller is run after the user has manually deleted the files. This causes the msi to look for the .exe which is to be run as a custom action, fails because the file doesn't exist and causes the uninstallation to abort.

How to not run the custom action if the file doesn't exist?

I have not found any similar query so I'm posting here. Please help me out if you can

1
Please share error outputcaptain-yossarian
What does this executable actually do on uninstall? The real solutions are generally: 1) use a dll custom action embedded in the setup, 2) eliminate the need for the custom action altogether. Remember that some cleanup done on uninstall can be replaced by instructions to the user for cleanup if they want to. Very often what you leave behind on uninstall are user data files or settings files that may potentially be desired for the user to keep (if they reinstall for example). You should generally not delete any user data. Doing so often causes more problems than leaving the data in place.Stein Åsmul

1 Answers

0
votes

See this link: https://docs.microsoft.com/en-us/windows/win32/msi/searching-for-existing-applications-files-registry-entries-or--ini-file-entries

You need to search for the file, and (if found) store the path to the file in a property (if not found, the value of the property will be an empty string). Then use that property as a condition for your custom action in the InstallExecuteSequence table.

For example (this example would change slightly if the file existed inside your Installer, since it would use the CompLocator table instead of the DrLocator table):

Add an entry to the AppSearch table, such as:

Property........Signature_
MYFILEEXISTS....AppSearchSignature

Add an entry to DrLocator table, such as:

Signature_.............Path
AppSearchSignature.....C:\PathToYourFile    

Add an entry to the signature table, such as:

Signature.............Filename
AppSearchSignature....FileToSearchFor.exe   

And finally in the InstallExecuteSequence table, find your custom action and give it a condition of:

MYFILEEXISTS<>""

In other words, only run the custom action if the path to the file exists.

Something like that should do it...