Updating/reinstalling over files in use - Advanced Installer Community
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Updating/reinstalling over files in use

Hello,

The installer I'm writing will typically be used to update executable and library files that are located on a shared drive (this is one of the common deployment scenario for our software).

As it happen, a common issue for deployment is that users on another system could very well be running the application in which case the installation should fail.

Since the application is made of many different executables, it is possible for the installer to actually do a partial installation before it fails: that should be prevented.

In the old installer, the process started by copying the main application libraries first (dlls loaded by every executable path of our app and kept locked as long as the application runs). If that failed, the no partial overwrite would be done since that initial file copy operation would fail with a "file already in used" error.

I'm trying to replicate this behavior but I actually had no luck doing so: the installer will happily overwrite executable files before updating the library components.

The result is that the installation is incomplete and unusable any more: the executables already copied are not usable any more because the common library files have not been updated.

I have tried moving these libraries to a different feature but this does not solve the issue since I can't find a way to force that feature to be installed first either.

Ideally, I would have loved for the installer to verify that it can overwrite ALL the target files before even starting the copy operation.

How can I solve that problem ?
Thank you
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Updating/reinstalling over files in use

Hello,

In the File table from the Table Editor page you can see the sequence for all the files from your project.

In the Advanced Media Tab you can perform extensive customization for the media volumes and CABs. This tab appears only if the Advanced CAB Layout option is selected in the Configuration tab.

Please note that the dialog ("FilesInUse" on XP and "MsiRMFilesInUse" on Vista) is shown automatically by Windows Installer during the InstallValidate standard action when the installer checks if any file is in use and if so, it displays that dialog. This is managed automatically by Windows Installer.

This dialog can be avoided by running a Detect and Stop custom actions before the install/uninstall process which stops the processes which use the files.
Please take a look on the Detect or stop a process How-to article which may be useful to you.

Also, you can take a look on our How is Files in Use determined - can it be overridden? forum thread which debates a similar subject.

Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

Thank you for your answer.

- I don't see the table editor because I'm using the professional version (for this installation anyway).
- Regarding the media volume: I can't find any way to specify in which order to copy operation must be done. Must I create a new cab and move all executable to the second one, leaving the library files in the first one ? In this case, all my files are inserted through either dynamic directory import and assigned to features: How can I script that ?
- I have confirmed that the validation performed by windows is insufficient. It will only work for local files when the current user is actually executing the file (my installer runs without elevation). That should be OK, however, if I can prevent the user from blowing up his install by making sure that the first files deployed are the files that are used by all applications.
- The custom actions are useless because the process can be running on a different machine (and that's actually the case most of the time when the issue happens). I really need to go through the process of trying to overwrite the file itself to know if it's possible (even renaming it is not good enough and I can't delete it because if the user cancels the installation, then it can't be rolled back).

Regards,
Stephane
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

Hello,

I'm sorry to bump this but it's really important that I find a solution for this issue otherwise I cannot replace our existing installer.

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

Re: Updating/reinstalling over files in use

Hi Stephane,

An upgrade installation consists in two parts:
  • the uninstall of the old product version
  • the installation of the new product version
As I said, the installer should checks if any file is in use during the InstallValidate action and if so, you should be prompted with the MsiRMFilesInUse dialog:

Code: Select all

The InstallValidate action notifies the user if one or more files to be overwritten or removed are currently in use by an active process.
So, the installer should not start overwriting the files from the target machine.

However, in order to have a better view about this, can you please send us the .AIP (project file) and a verbose log of the installation process to support at advancedinstaller dot com so we can investigate it? If it contains confidential information you can send us a small test project which reproduce this behavior.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

Hello Dan,

Thank you for coming back to me.

I'm afraid, however, that you do not understand the issue I'm refering to. First of all, this will not always be an update in the sense you're using that word: it won't be upgrading a AI installer with a new version of the same. Indeed, when I first release the new installer, it will NEVER be an upgrade. Nevertheless, the target executables will be in place and I cannot force the users to uninstall the application first.

Even later, it will not always be an actual update: it is fairly common for users to change machine and simply reused the installation on their network: my application is typically deployed centrally on a shared server and it is fully self-installing on the machine that runs it. In a sense, the installer is just a glorified unpacker.

This means that the "uninstall" part cannot be trusted to run.

As for the InstallValidate action, as I tried to explain, is simply fails to identify the files in use except through a destructive process (either requesting an exclusive lock on the file - which it doesn't do - or trying to overwrite the file).

Again, there is a very simple, trivial solution to this all: make sure the first file to be deployed are ALWAYS the ones that will be locked as soon as the application is running.

I will follow your request and send you the API I write, along with a verbose log retrieved from a test run of the problematic scenario.

Again, thank you for your help,
Stephane

Edit: I have sent you both the project and the verbose log file you requested.
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

Hello,

I'm sorry to bump this (again) but I still haven't received a satisfactory answer to this question or an answer to the project I sent via email.

Thank you,
best regards,
Stephane
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Updating/reinstalling over files in use

Hi Stephane,
it is fully self-installing on the machine that runs it
Can you please give us more details about this? Is it a Windows Installer based setup?

However, I don't understand what the problem is with the update process. Since the application is installed locally, on each user machine, why there is a problem when you "update" the application on the server?
I will follow your request and send you the API I write, along with a verbose log retrieved from a test run of the problematic scenario.
Can you please let us know your emaill address or send us once again the email? I did not noticed any email that reference this forum thread.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

Can you please give us more details about this? Is it a Windows Installer based setup?
Basically no. What I mean is that, once the application has been installed on a central location, any client can access it without installing anything on the local machine. My deployment is more complex than that but, for the purpose of the installer, it is similar to simply deploying an exe file with no required modification at all to the registry or anything else. All that is actually required for running the application is have access to the exe file and launching it.
However, I don't understand what the problem is with the update process. Since the application is installed locally, on each user machine, why there is a problem when you "update" the application on the server?
Ok, I'll try to explain both the architecture and the issue more clearly. Sorry if it's a bit long. Let me know if this isn't clear:

Basic architecture
MyApplication.exe is made of many different executable modules (other exe files) that implements various features. All of these modules depends on several shared libraries (DLLs and BPLs) that are loaded immediately when a module starts and only released when the module exits.

How it is deployed in the problematic scenario
In this case, here is the typical deployment:
- The network admin creates a network share to host the application (call it \\srv\application1)
- The network admin runs the installer from a random client system (or directly from the server) and specify \\srv\application1 as the application's installation location ([APPDIR]).
- Users will simply invoke \\srv\application1\MyApplication.exe to start the application.

How the problem occures

- An admin receives an update for the application. He may or may not be using the same system as the one he initially used for deployment (that is typically the case when several users are "managing" the application).
- At the same time, other users are using the application. The admin request them to go out but they might not actually follow the instructions (this is, sadly, very common) and that could leave some application running. Let's imagine, for instance, that one user has left the "MyApplicationDashboard.exe" executable running. That application locks the shared library files but does not mock the main executable (MyApplication.exe).
- The admin, believing everyone is out of the system, initiates a deployment. The installer will prompt for a destination and he will select \\srv\application1.
- The isntaller will perform its preinstallation cehcks: no files in \\srv\application1 is locked from the admin's system and neither is any of the application's executable running on it. The installer then (incorrectly) assumes that the installation can safely be performed and starts copying files.
- Since I couldn't specify the other in which the various files are deployed, the installer will do that more or less randomly. Statistically, it will deploy several executable modules before reaching either "MyApplicationDashboard.exe" or one of the shared libraries.
- When the installer finally reachs one of these files, it encounters a shared access denied error and will prompt the administrator for instructions.
- If the admin goes to each user and terminates the still running applications (all of them) before returning to the installer and click "try again", all is well.
- If the admin does NOT do that, however, the result is always a half-broken installation: all executables that already have been deployed will fail to start because the shared libraries are not the ones they where compiled for.

I know it seems like a far-stretched scenario but it is, in fact, one we experience frequently: a lot of our customers are small to medium financial firms with little or no proper IT support. One of the reason they chose our system is that it is trivially easy for users to deploy and maintain it themselves with little or no external IT help. The typical user of the application it not very proficient with computers and technology but quite focus on their core business. Many will fail to follow simple instructions and that results if frequent deployment issues similar to what I'm describing. The problem is made worse by the fact that we do release new version quite often.

I will resend the email containing my project to the same address, placing the link to this thread in the subject for easy identification.

Thank you for your help,
regards,
Stephane
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

I just resent the email with my project. If you have not received it, please let me know.

Regards,
Stephane
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Updating/reinstalling over files in use

Hello Stephane,

Thank you for your detailed feedback. Unfortunately, the only solution you can try will be to upgrade your project to an "Enterprise" project type and modify the installation sequence number for all of your installation files as you need (to set the file installation order you want). Just go to "Table Editor" page, select the "File" table and edit the "Sequence" field of your files as you need. The file with the lowest sequence number is installed first and the one with highest sequence number is installed the latest.

If you do not have an Enterprise license, you can install the AI application on a new machine (even on a VM) and run it in trial mode. Then you can build your setup package in "Enterprise" mode and edit the file installation sequence number and see how this workaround suits to your needs.

As a side note, as a manual workaround solution you can advise your server admins to temporarily unshare (stop sharing) your central installation network folder during the product update. This way you can make sure there will be no handle on your target file.

These are the only suggestions I could think off.

Let us know if you have any further questions.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Fulgan
Posts: 101
Joined: Mon Feb 27, 2012 10:42 am

Re: Updating/reinstalling over files in use

Hello,

Thank you for your answer.

I already tried to change the order of deployment with the table editor but it does not seems to work: when the installer reaches the item with the modified sequence number, all it does is say that it cannot find the resources.

Besides, since the list of files to deploy is built dynamically, there is no way to integrate that manipulation in my build script and, finally, the license I purchased for the automated build is a professional one so it doesn't even have these capabilities.

I will attempt to work on different ideas. Indeed, I might need to write a custom module or script that attempts to lock one of the library files during the preparation phase of the installer: if it succeeds, the application is probably going to succeed.

Stephane
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Updating/reinstalling over files in use

You're welcome Stephane. Hopefully you will manage to find out a workaround solution for a foolproof deployment.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”