clint
Posts: 135
Joined: Fri Jun 19, 2009 9:46 am
Location: Germany

File overwrite condition

Hi,

How do I condition a file in the file operations to always overwrite when installing or patching, but not when repairing?

This is a non-versioned template file, which sometimes needs to be manually updated between installation versions without using a patch (I know: Bad practice).

Thank you!

Regards,
clint
Dan
Posts: 4529
Joined: Wed Apr 24, 2013 3:51 pm

Re: File overwrite condition

Hi Clint,

In order to achieve that you can use the following statement in the Condition field from the file properties dialog:

Code: Select all

AI_INSTALL_MODE = "Repair"
Please let us know if you have other questions.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
clint
Posts: 135
Joined: Fri Jun 19, 2009 9:46 am
Location: Germany

Re: File overwrite condition

Hi Dan,

Thank you. I didn't realize the AI_INSTALL_MODE = "Repair" property (didn't see it in the list either)

But, I am still somewhat confused, though I tried to understand from the Help file prior to my post.

What you suggested to use, means that the file will be preserved whan repairing:

i.e: "Do not overwrite existing file when repairing"

But, when Patching, what will happen?

Will the file will be:

1. ...always replaced, even if the existing file is newer
or
2. ...replaced only if the existing file is older.

In the case repairing, I need what you suggested.
But in the case of patching or a new product, I need #1.



Regards,
clint
Dan
Posts: 4529
Joined: Wed Apr 24, 2013 3:51 pm

Re: File overwrite condition

Hi Clint,

I think a solution for you is to create your own custom action that is running on the Repair sequence which will create a back up for the related files and then restore them. Please take a look on the Standard actions executed during a repair article which may be useful to you.

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

Then you can go in the “Custom Actions” page and add a predefined Launch attached file custom action with sequence. This type of custom action can execute an application (EXE or DLL) or run a script (VBScript or Java script). Also, the source file will be embedded in the MSI file but will not be deployed at install time with the other application files.

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
clint
Posts: 135
Joined: Fri Jun 19, 2009 9:46 am
Location: Germany

Re: File overwrite condition

Thank you Dan for your help.

But I think we will need to come up with another solution.

Could you just please additionally answer the question in my last post, what happens with the operation:
1. "Never overwrite existing file" and Condition = FALSE
2. "Never overwrite existing file" and Condition = TRUE

I mean, when according to the condition 1, the existing file should indeed be overwritten, then will it overwrite no matter if the existing file is newer or not?

Thank you!
clint
Dan
Posts: 4529
Joined: Wed Apr 24, 2013 3:51 pm

Re: File overwrite condition

Hi Clint,

Indeed, according to the condition 1, the existing file should indeed be overwritten.
Please keep in mind that the Condition field is a boolean expression which must be true for the action to be executed.

You can also take a look on the File Versioning Rules article which may be useful to you.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”