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!

yusuf
Posts: 7
Joined: Tue Apr 25, 2017 2:00 pm

Overwrite install file

Hi,
I have a synchronized folder which being installed. Among the many files in the folder is User Database Configuration File. The configuration file is xml based but have vgs extention. The file in the install folder has empty node initial data, which looks like

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<Connections>
</Connections>
Since this is database configuration, it is typical it will persisted between different version install. I want to give a chance to the user to over ride the file during install. The typical process is
1. User browses to a file locally on his/her machine and selects existing configuration file
2. If file is selected, overwrite the install file with user file during install

I have a dialog created that allows the user to select the file. How to do go about overwriting an install file?

Thanks
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Overwrite install file

Hello,
1. User browses to a file locally on his/her machine and selects existing configuration file
For this, you could use our "Browse for file" custom action. It could be configured without sequence and executed as a publish event on a "Browse for file" push button placed on a dialog.
This custom action will generate three properties :
1. AI_OFN_FILENAME property. Its value is resolved to the name of the chosen file, eg. "sample.exe"
2. AI_OFN_DIRECTORY. Its value is resolved to the path of chosen file, eg. "C:\Users\Sorin\Desktop\"
3. AI_OFN_FILEPATH. Its value is resolved to the fil path of the file, including its name, eg. : "C:\Users\Sorin\Desktop\sample.exe"
2. If file is selected, overwrite the install file with user file during install
For this you can create you own custom action.

For example, you can create your custom action as a custom action written in C# or a custom action written in C++.


You can also use the VBScript or a PowerShell custom action to implement this functionality.

This custom action should copy the file picked by the user to your needed location. This custom action should be "deferred type" and placed after "Add Resources" in the "Install Execution Stage" as you need to overwrite a file deployed by the package.

When writing this custom action you should use the above properties to reference your file.
Here you could find more information regarding how you should reference installer properties in C#/C++/PowerScript/VBS scripts custom actions: How to set an installer property using custom actions

Also, please also take a look on how you could access installer properties in deferred custom actions : Pass installer properties in deferred custom action

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”