Problems with files being removed - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

AndrewMilne
Posts: 6
Joined: Wed Jan 20, 2010 11:38 am

Problems with files being removed

I have a product, lets call it Bob V1.0, when its uninstalled it removes all its files correctly. Unfortunately we forgot to mark a couple of components as "permanent" so its removing files we would like it to leave behind in the My Documents folder.

I've already fixed this for our new V2.0 release. The problem however is during an upgrade from V1.0 to V2.0 MSI uninstalls V1.0 for us, deleting these files.

I need some way to prevent this or fix it. I cant update or change the V1.0 installer, its too late for that, but I was wondering if there is something I can do in the V2.0 installer prior to it removing V1.0 to effectively remove the problematic components from the MSI database, leaving the files behind, that way when V1.0 is uninstalled it will not know to delete the My Documents files.

My only other option is to copy the files and restore them after the V1.0 removal and I'm worried about all the corner cases of that script (different users doing V2.0 install to the V1.0 etc.) and would like to avoid it.

Any help is greatly appreciated, this has become a bit of a hot issue for me.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Problems with files being removed

Hello Andrew,

I am afraid I was going to suggest the backup/restore alternative too. I am aware of no better solution for this.
However I do not see a problem in using the above approach, it should work fine.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
AndrewMilne
Posts: 6
Joined: Wed Jan 20, 2010 11:38 am

Re: Problems with files being removed

Thanks, I guess its the backup method then.

My best guess (I'm not really that experienced with Windows Installer or Advanced installer having inherited this project in a mostly complete state) is that I need to backup the files sometime before it invokes the remove (CostFinalize?) and then restore them after the old product is removed (InstallFinalize?)?

I'd probably look to do this in vbscript but what's the best way to get the installed location of a component in vbscript? I know you can use MsiGetComponentPath but I cant find any documentation on how to use that in a script just in a C++ program? I was looking at the windows installer automation interface and found Installer.OpenProduct but I cant use that in a custom action.

Any suggestions, hints, gratefully accepted.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Problems with files being removed

Hi Andrew,

A better and easier way to achieve this is using a File Search. The full path to the found file would be stored in a property which you can later use in your backup/restore script. You can fine-tune the search to avoid finding other files than the ones intended.

Searches can be done through the Search page in Advanced Installer. Just right click in the "Searches" pane and add a "New File Search". Right click again on the created search and add a folder location to restrict the search to a certain folder.

Let me know how this works for you.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
AndrewMilne
Posts: 6
Joined: Wed Jan 20, 2010 11:38 am

Re: Problems with files being removed

I thought about that but unfortunately the installer places entries in the my documents folder of the user who does the install. The product then places them in the my documents directory of other users when they run the product if the files are missing (we get lots of installs on boxes used by more than one account).

The remove script will only be deleting the ones by the original installer so a search may not return the correct one.

Long term I plan to change how this entire My Documents install process is handled to better support this but in the short term I have to deal with the current set-up.

A bit more digging has turned up the Installer.ProvideComponent() function which I'm hopping may return the info I need.
AndrewMilne
Posts: 6
Joined: Wed Jan 20, 2010 11:38 am

Re: Problems with files being removed

After a lot of investigation I've finally got something that seems to work, I thought I would post it here for reference.

A VBScript with:

path = Installer.ComponentPath("<product code>", "<component code>")

Will work, however the <product code> is not the product code reported in advanced installer as the product code when I re-open the aip file used for the release of the old product. It is the product code as reported by Microsofts WiLstPrd.vbs script, not sure why I'm seeing different values.

Interestingly digging in the aip file itself shows two product codes

<ROW Property="ProductCode" Value="1033:<code1> 2057:<code2> "/>

AI reports <code1> in the GUI when I ask it for the value of the product code but <code2> is the one I want. Does anyone know why there are two values?
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Problems with files being removed

Hi,

If your package supports multiple languages, then each language has its own product code. To view all product codes, go to Project->Options->Project IDs.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”