kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Custom action to copy user option files before upgrading

Sat Sep 17, 2022 6:04 pm

Hi, I need to (1) copy (preserve) user option files by copying Documents/MyCompany/MyApp/* to Documents/MyCompany/MyApp.BeforeInstall before the installer runs and overwrites the options files with new file formats and contents, (2) run the installer to upgrade the app and files, and (3) run my custom program (many DLL files) to inject all the preserved user options into the newly-upgraded option files and remove the MyApp.BeforeInstall folder. My custom pre-install file is actually a collection of 10 DLLs. My post-install custom file also consists of many DLLs.

I have tried launching an installed file, but that failed because the pre-install custom action file was not yet installed. I also tried launching an attached file, but I think only the .exe file was attached without all the supporting DLLs.

Q1. What is the best practice for running pre-install and post-install customization actions when the custom programs consist of many DLLs?
(My app has hundreds of user-customizable xml files, so the upgrade problem is somewhat complex.)

Q2. Is there a documentation example for this kind of best practice procedure? Is it best to use attached files or installed files?

I am a newbie. After reading and watching some videos on MSIX packages, I am wondering if the best practice is to ship all the upgraded option files in a side folder, and do the entire upgrade of app data files within the application when it first boots. That way the incoming new data/option files would be completely separate from the active user data/option files and the installer would not have to deal with the problem of upgrading app data files. Currently I am NOT using MSIX - I just use an .exe installer.

Thank you.

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

Re: Custom action to copy user option files before upgrading

Tue Sep 20, 2022 1:04 pm

Hello,

In order to backup a folder during upgrade, you can follow the article created by my colleague Danut:

Backup file/folder during upgrade

If your custom action that backups the folder is a .DLL file, then you can add the respective .DLL file as a "Temporary File". This way, the DLL file should be available when you are trying to launch it.

Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process.

Hope this helps!

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

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Re: Custom action to copy user option files before upgrading

Tue Sep 20, 2022 5:50 pm

Hi, thank you for the helpful reply and article links! They helped a lot. I have two more follow-up questions:

1) Would this procedure be the same for an MSIX installation?

2) You say I can add a DLL file as a "Temporary File" - wouldn't it need to be an executable file? Or do you load and execute both kinds of files equally well?

Thank you

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

Re: Custom action to copy user option files before upgrading

Thu Sep 22, 2022 2:24 pm

Hello,

You are always welcome! I'm glad the articles were helpful.

Please allow me to address your questions below:
1) Would this procedure be the same for an MSIX installation?
Well, not quite. Please note that MSIX is quite different compared to MSI/EXE packages. First of all, MSIX does not have support for custom actions (basically what we need to achieve that).

More information about this in the following thread:

Custom Actions do not work for MSIX package?
2) You say I can add a DLL file as a "Temporary File" - wouldn't it need to be an executable file? Or do you load and execute both kinds of files equally well?
Yes, you can call a function from a DLL file using Advanced Installer. For this, we have the predefined custom actions:

Call function from attached native DLL

(and the other two right below the one I've linked above)

You can also have an EXE, sure, and you would launch that through a "Launch File" custom action.

Hope this helps!

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

kkkwj
Posts: 88
Joined: Thu Mar 01, 2007 10:45 pm

Re: Custom action to copy user option files before upgrading

Thu Sep 22, 2022 6:10 pm

Thank you for the nice answers and links!

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

Re: Custom action to copy user option files before upgrading

Mon Sep 26, 2022 2:46 pm

You are always welcome!

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

Return to “Common Problems”