Sandeep Kokate
Sandeep Kokate

Reputation: 845

MSI Installer revert the modified installation files if application starts with other user

I have a scenario, On a particular machine, I am installing my custom software with MSI installer. MSI installer is created with PerMachine tag, so software is available for all the users of that machine. Now,

  1. I installed the software on C:\MyApp\ directory.
  2. Then I modified a few configuration files present in C:\MyApp\Config folder to make sure the software connects with my other services.
  3. I started the application, it's working fine.

Now, on the same machine, I logged in with another user.

  1. I started the application.
  2. MSI windows popup with some progress bar for installation.
  3. It vanishes and the application starts but fails to load.
  4. But all the files I have modified are reverted now, I need to again modify those.

Few points:

  1. My installation direcotry is C:\MyApp, not any custom user directory. So modified files should be for all the users.
  2. I think MSI is rolling back changes when I logged in with the new user.

How to stop this?

Please help

Upvotes: 2

Views: 430

Answers (1)

Stein Åsmul
Stein Åsmul

Reputation: 42126

Self-Repair: Windows Installer self-repair is the cause of the behavior you see. See the link for an explanation of what happens. See more here - several links with information on self-repair from various angles.

Short Explanation: Essentially the launching of an advertised shortcut triggers an integrity check of the installed files and if a file or registry setting is found to be missing a self-repair ensues. It will put in place missing files and settings. During this process it will sometimes overwrite changed settings files - the problem you describe (due to various file overwrite oddities of Windows Installer - a long answer with various hints).

Fix?: My preferred fix for this is to not install the settings files and update them, but to rather have your application generate them on first launch - either one file per user or a shared one for all users. You can also use a read-only copy of the settings file that you install to copy to a new file that you generate and update. I also recommend you put these files in a writable location in the user profile and not in the main folder. Your setup will never interfere with these generated files. You can also try to set the hosting component for the files "permanent" and "never overwrite". Not very neat. Here is a whole rant on the subject. The very best solution - in my opinion - is to keep settings in databases and get them on launch. This allows good control of all settings. Look out for network and firewall issues.

I hope this answers your question. Are you installing IIS files? I find commercial tool Advanced Installer to have the better feature list for IIS installation - though I lack enough data to conclude. Some videos here: https://www.youtube.com/c/advancedinstaller/search?query=IIS - WiX is also very good, but without the nice GUI of Advanced Installer.

Note: you really should not install to the root of C:\ anything at all. Windows Installer actively tries to make it hard, and side-effects are likely. You can, however, target the IIS folders - wherever they are located.

Update: I found this old answer on how to allow selective update of settings files - I had to resurrect the linked forum answers from Wayback.

Upvotes: 2

Related Questions