Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

MSI Open Database to get list of file paths to the installed files in a custom dll

Fri Sep 20, 2019 10:39 am

Hello,

Here's a sample project where you can see how to interact with the MSI database at runtime, through a custom action.
The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file. For debugging purposes, the full path of each file will be written in the log. There is no need to perform a full install. To create a log file, please use the following command line statement:

Code: Select all

msiexec /i <path_to_msi> /L*V <path_to_log>
Here is what you need to do:
  • In your Advanced Installer project, please add the files from the related folder under the same component
  • In your custom action you need to do this:
    • Iterate through the files from the File table and get those files that have the related component.
    • Compose the full path (folder's path + file name)
To execute you custom action, please use the predefined Call function from attached native DLL custom action.

If you will create a log for the sample .msi, you should see the following in the log:

Code: Select all

Calling custom action Get files path from same component!Get_files_path_from_same_component.CustomActions.GetFilesPath
Begin GetFilesPath custom action
Database open
Database openned
File table openned
The files that are assigned under the *OtherFileCopy2* component are:
C:\Program Files (x86)\Your Company\Your Application\aFolder\OtherFileCopy2.txt
C:\Program Files (x86)\Your Company\Your Application\aFolder\OtherFile.txt
C:\Program Files (x86)\Your Company\Your Application\aFolder\OtherFileCopy.txt
C:\Program Files (x86)\Your Company\Your Application\aFolder\OtherFileCopy3.txt
C:\Program Files (x86)\Your Company\Your Application\aFolder\OtherFileCopy4.txt
End GetFilesPath custom action
Best regards,
Dan
Attachments
How to get list of file paths to the installed files in a custom dll.zip
(722.05KiB)Downloaded 1899 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”