Joshr
Posts: 33
Joined: Mon Dec 14, 2015 5:40 pm

RemoveFiles operation not removing file

Fri Jan 29, 2021 8:11 pm

Hello,

I unfortunately have another issue I do not understand.

We have a configuration file, Configs.xml, that is installed with our product. The file is associated to the Configs.xml component and is configured to never overwrite an existing file. There is also a Modify XML action which changes one of the configuration values in Configs.xml based on data entered into the installation wizard by the user. This action is associated with a component which is always installed to ensure it always runs.

All of that works fine.

During the uninstall process, there is an option to remove all configuration data. This option sets the property REMOVE_CONFIGURATION to 1 if checked. There is also a Remove File operation, called Configs.xml, and set its condition to REMOVE_CONFIGURATION="1". The Remove File operation is associated with a component that is always removed to ensure it always runs.

Here are some screenshots showing the setup in Advanced Installer:
configfiles.jpg
configfiles.jpg (35.64KiB)Viewed 1758 times
The Remove File settings:
removeconfig.jpg
removeconfig.jpg (61.39KiB)Viewed 1758 times

According to the log captured during uninstall, the REMOVE_CONFIGURATION property is set to 1, but the Configs.xml file is NOT removed. Other Remove File operations execute as expected:

Code: Select all

Action start 17:50:11: ExecuteAction.
...
MSI (s) (9C:B0) [17:50:11:740]: PROPERTY CHANGE: Modifying REMOVE_CONFIGURATION property. Its current value is '0'. Its new value: '1'.
...
MSI (s) (9C:B0) [17:50:19:254]: Executing op: SetTargetFolder(Folder=C:\Program Files (x86)\CommSys\ConnectCIC\)
MSI (s) (9C:B0) [17:50:19:254]: Executing op: FileRemove(,FileName=request-response.xsl,,)
MSI (s) (9C:B0) [17:50:19:254]: Executing op: FileRemove(,FileName=CommonFunctions.vbs,,)
MSI (s) (9C:B0) [17:50:19:254]: Executing op: ProgressTotal(Total=564,Type=1,ByteEquivalent=175000)
As you can see above, REMOVE_CONFIGURATION is set to 1, but Configs.xml is not removed. The CommonFunctions.vbs file (shown in the screenshot) which also has a RemoveFile action, is removed as expected.

Joshr
Posts: 33
Joined: Mon Dec 14, 2015 5:40 pm

Re: RemoveFiles operation not removing file

Tue Feb 02, 2021 7:38 pm

I'm going to put the answer here in case anyone else runs into this problem.

After wasting four days trying to figure this out, it turns out the issue is with the "Do not overwrite existing file" checkbox on the file settings. Windows Installer does not actually avoid overwriting the file; instead it creates a backup, lets the install replace the file, and then restores its backup.

This operation also occurs during the uninstall process: the file is backed up, removed, and then restored.

To fix this, I had to add a condition to the file after selecting "Do not overwrite existing file". The condition I added was

Code: Select all

AI_INSTALL OR (REMOVE="ALL" AND REMOVE_CONFIGURATION="0")
This tells Windows Installer to restore its backup only during an installation or if the user requested to remove the configuration during uninstall, which is a checkbox I added to the UI.

Catalin
Posts: 6542
Joined: Wed Jun 13, 2018 7:49 am

Re: RemoveFiles operation not removing file

Thu Feb 04, 2021 9:05 pm

Hello,

Thank you for your followup on this and for sharing your solution with us!

I am sure other users facing a similar scenario will find this useful.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”