MSI self repairing a program update
I searched around and did not find this exact problem, or how to resolve, so I aplogize if this has already been answered. Here is my issue:
I have a repackaged application that I did in AdminStudio. The repackaged app works fine, the msi program installs successfully on target machines. The first time the program runs, it wants to do an update of itself to ensure it has the latest files. It runs the update and downloads the latest files.
The next time the program runs, the Windows Installer sees that it's original files are different, and it 'self-heals' back to the original files. Then, my program sees that the files are out of date, and wants to go back out and update itself.
I could go on, but I think you get the picture. What is the best method for avoiding this behavior?
thanks,
Scott
I have a repackaged application that I did in AdminStudio. The repackaged app works fine, the msi program installs successfully on target machines. The first time the program runs, it wants to do an update of itself to ensure it has the latest files. It runs the update and downloads the latest files.
The next time the program runs, the Windows Installer sees that it's original files are different, and it 'self-heals' back to the original files. Then, my program sees that the files are out of date, and wants to go back out and update itself.
I could go on, but I think you get the picture. What is the best method for avoiding this behavior?
thanks,
Scott
0 Comments
[ + ] Show comments
Answers (25)
Please log in to answer
Posted by:
GB1
19 years ago
I'll be interested to know everyone elses opionions on how they go about this, but I would:
Put the files that get updated in a sub feature on there own with no entry points. You can make sure there are no keypaths for the components in that feature too if you want, but with no entry points you should be ok.
Graham
Put the files that get updated in a sub feature on there own with no entry points. You can make sure there are no keypaths for the components in that feature too if you want, but with no entry points you should be ok.
Graham
Posted by:
WiseUser
19 years ago
It's unfortunate that the application does this, since MSI is supposed to be managing these files.
It's also very strange because:
1) A change in a file keypath should not trigger a repair (only a missing file keypath).
2) A later file should not be overwritten by an older one.
You can check which component is broken and triggering the repair using the event viewer.
As GB1 rightly said, it may be safer to move the affected component(s) to another feature. Although, I'd consider moving them to an independent top level feature.
It's also very strange because:
1) A change in a file keypath should not trigger a repair (only a missing file keypath).
2) A later file should not be overwritten by an older one.
You can check which component is broken and triggering the repair using the event viewer.
As GB1 rightly said, it may be safer to move the affected component(s) to another feature. Although, I'd consider moving them to an independent top level feature.
Posted by:
WiseUser
19 years ago
Not only a missing file keypath can trigger a repair. Different versioning, modifydates or languagecodes can also trigger a repair. If you have a "d" in your REINSTALLMODE property the file will be replaced when differen or missing.
We seem to keep having this age-old debate over and over again.
Unfortunately, nobody has ever been able to produce a single shred of evidence that the above statement is true. Until someone does, I will continue to maintain that only "missing" file keypaths trigger repairs.
Here's a link to the last debate we had about this:
http://itninja.com/question/faulttree-10546&mpage=1&key=ᚑ
And what makes you think his REINSTALLMODE property might have a "d" in it during a self repair, when the default is "pocmus"? Don't you think he'd know if he'd gone to the trouble of changing it?
Posted by:
TomB
19 years ago
I have had to do this for a few in house applications.
I just asked the files that would need to be updated and moved them to a separate top feature. Then I removed all the Key paths for each component. You should also make sure there are no Com,typlib, AppID entries for any DLL, OCX, and other files that may need to be updated. If the files need to be registered you will want to use the Selfreg Table.
If you are removing the key path for the application EXE file, you will not be able to make it an advertised shortcut. You will need to point it directly to the EXE file.
If you do file hashing, I would also avoid creating hashes for any of the files that are updated.
You can also edit the MSI property table and set the REINSTALLMODE = pmus
This should allow the MSI to not trigger a repair on those files or reinstall them if a repair is done.
However, WiseUser is correct is I do not think it should keep repairing like that. Would your application update a registry entry that is installed as a key path in your msi?
I just asked the files that would need to be updated and moved them to a separate top feature. Then I removed all the Key paths for each component. You should also make sure there are no Com,typlib, AppID entries for any DLL, OCX, and other files that may need to be updated. If the files need to be registered you will want to use the Selfreg Table.
If you are removing the key path for the application EXE file, you will not be able to make it an advertised shortcut. You will need to point it directly to the EXE file.
If you do file hashing, I would also avoid creating hashes for any of the files that are updated.
You can also edit the MSI property table and set the REINSTALLMODE = pmus
This should allow the MSI to not trigger a repair on those files or reinstall them if a repair is done.
However, WiseUser is correct is I do not think it should keep repairing like that. Would your application update a registry entry that is installed as a key path in your msi?
Posted by:
WiseUser
19 years ago
Those are file versioning rules which apply once an upgrade is underway. What I've been talking about is what will actually "trigger" the repair process when an entry point (such as a shortcut) is invoked.
If you know a way of changing the default "REINSTALLMODE" value for automatic "self repairs" that occur when a broken component is found, I'd be interested to know how. TomB mentionned that it is possible to hard-code the "REINSTALLMODE" property within the property table of the MSI, but I'm pretty sure that won't affect "automatic" self repairs.
If you know a way of changing the default "REINSTALLMODE" value for automatic "self repairs" that occur when a broken component is found, I'd be interested to know how. TomB mentionned that it is possible to hard-code the "REINSTALLMODE" property within the property table of the MSI, but I'm pretty sure that won't affect "automatic" self repairs.
Posted by:
TomB
19 years ago
I have looked in the past and just now, and while I have been unable to find any documentation that states precisely that the REINSTALLMODE property is used when an MSI is repaired, I have also not found anything that says it is not.
If you review the MSI documentation the repair and reinstall sound as if they same are the same process, in which I believe they are.
If you look at the Windows Installer Functions you see the MsiReinstallProduct and MsiReinstallFeature, but no "repair".
So if the repair uses the reinstall functions then would it not make sense that it would use the REINSTALLMODE property?
A little more info:
MsiReinstallProduct = Reinstalls or repairs an installation.
MsiReinstallFeature = Validates or repairs features.
If you review the MSI documentation the repair and reinstall sound as if they same are the same process, in which I believe they are.
"Resiliency is the ability of an application to recover gracefully from situations in which a vital component is missing, or has been replaced by an incompatible version. By authoring an installation package and using the Installer Functions, developers can use the Windows® Installer to produce resilient applications capable of recovering from such situations."
...
...
...
Use the installer to reinstall damaged shortcuts, registry entries, and other components without having to rerun setup.
If you look at the Windows Installer Functions you see the MsiReinstallProduct and MsiReinstallFeature, but no "repair".
So if the repair uses the reinstall functions then would it not make sense that it would use the REINSTALLMODE property?
A little more info:
MsiReinstallProduct = Reinstalls or repairs an installation.
MsiReinstallFeature = Validates or repairs features.
Posted by:
WiseUser
19 years ago
Thanks for the feedback ILikeBananas. I'm assuming that like me you've actually tried the "REINSTALLMODE" thing?
Yes TomB, a repair is nothing more than a reinstall. And of course the "REINSTALLMODE" property is used during a reinstall. Nobody has ever suggested anything different - certainly not me. What I'm discussing is what event can actually cause this repair or reinstall to occur in the first place (automatically).
Here's how to observe what I'm talking about:
1) Create a basic MSI with with a single feature, single component, single executable file (keypath), and a shortcut to the executable.
2) Hardcode the "REINSTALLMODE" property to something other than "pocmus".
3) Install the newly created MSI.
4) Switch verbose logging policy on:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer]
"Logging"="icewarmupv"
5) Delete your executable file (keypath) and then invoke your shortcut in order to trigger a self repair.
6) Check the value of the "REINSTALLMODE" property within the log file (in %Temp%) - you should find that it's not the value that you hardcoded.
However, if you now ran "Msiexec /i YourPackage.msi REINSTALL=ALL /qb" you most probably would find your hardcoded value of the "REINSTALLMODE" property in the log file.
Yes TomB, a repair is nothing more than a reinstall. And of course the "REINSTALLMODE" property is used during a reinstall. Nobody has ever suggested anything different - certainly not me. What I'm discussing is what event can actually cause this repair or reinstall to occur in the first place (automatically).
Here's how to observe what I'm talking about:
1) Create a basic MSI with with a single feature, single component, single executable file (keypath), and a shortcut to the executable.
2) Hardcode the "REINSTALLMODE" property to something other than "pocmus".
3) Install the newly created MSI.
4) Switch verbose logging policy on:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer]
"Logging"="icewarmupv"
5) Delete your executable file (keypath) and then invoke your shortcut in order to trigger a self repair.
6) Check the value of the "REINSTALLMODE" property within the log file (in %Temp%) - you should find that it's not the value that you hardcoded.
However, if you now ran "Msiexec /i YourPackage.msi REINSTALL=ALL /qb" you most probably would find your hardcoded value of the "REINSTALLMODE" property in the log file.
Posted by:
TomB
19 years ago
I see what you are talking about. Sure enough the log has the the property REINSTALLMODE=pocmus, regardless of what is in the REINSTALLMODE property of the MSI.
Sorry for the confusion, I never noticed that in the log.
I would be interested if anyone finds out where this comes from or if it can be changed at all.
Sorry for the confusion, I never noticed that in the log.
I would be interested if anyone finds out where this comes from or if it can be changed at all.
Posted by:
amccombs
19 years ago
Posted by:
WiseUser
19 years ago
Which manual are you using? This is the one most people tend to use:
http://msdn.microsoft.com/library/en-us/msi/setup/windows_installer_start_page.asp
The direct link you wantis here:
http://msdn.microsoft.com/library/en-us/msi/setup/reinstallmode.asp
If it's not in your Property table, then it's not hardcoded.
http://msdn.microsoft.com/library/en-us/msi/setup/windows_installer_start_page.asp
The direct link you wantis here:
http://msdn.microsoft.com/library/en-us/msi/setup/reinstallmode.asp
If it's not in your Property table, then it's not hardcoded.
Posted by:
amccombs
19 years ago
I was looking at the same pages, but from the installed MSDN subscription.
So if REINSTALLMODE is not listed in the file's property table then I don't have a REINSTALLMODE feature?
I need to configure the installer project to install / repair files even if they are missing or a newer one is installed.
So if REINSTALLMODE is not listed in the file's property table then I don't have a REINSTALLMODE feature?
I need to configure the installer project to install / repair files even if they are missing or a newer one is installed.
Posted by:
TomB
19 years ago
REINSTALLMODE is like any Public Property. You can specify it on a command line or you can add the Property to the Property table and add your specific value to override the default setting. The default for REINSTALLMODE is "omus", so if you don't specify it you still have a REINSTALLMODE.
For what you would like to accomplish you might want to look at the file versioning rules for the installer.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/file_versioning_rules.asp
For what you would like to accomplish you might want to look at the file versioning rules for the installer.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/file_versioning_rules.asp
Posted by:
amccombs
19 years ago
Posted by:
WiseUser
19 years ago
OK. Here's the dummy version.[;)]
Command line options for "Msiexec.exe" are here:
http://msdn.microsoft.com/library/en-us/msi/setup/command_line_options.asp
Example:
Msiexec.exe /i mypackage.msi REINSTALL=ALL REINSTALLMODE=omus /qb
"omus" is the default. Check the SDK for other options.
Orca is an MSI database editor which is part of the Windows Installer SDK which can be downloaded from Microsoft. This DB editor will allow you to view, edit and add new properties in the Property table of any MSI.
I don't think I explain it any more basically than this?
If you still don't understand, I suggest that you explain in detail what you need to do.
Command line options for "Msiexec.exe" are here:
http://msdn.microsoft.com/library/en-us/msi/setup/command_line_options.asp
Example:
Msiexec.exe /i mypackage.msi REINSTALL=ALL REINSTALLMODE=omus /qb
"omus" is the default. Check the SDK for other options.
Orca is an MSI database editor which is part of the Windows Installer SDK which can be downloaded from Microsoft. This DB editor will allow you to view, edit and add new properties in the Property table of any MSI.
I don't think I explain it any more basically than this?
If you still don't understand, I suggest that you explain in detail what you need to do.
Posted by:
amccombs
19 years ago
Posted by:
WiseUser
19 years ago
Posted by:
amccombs
19 years ago
I am packaging a major release. If there are any patches released afterwords that mess up the system I want to make sure the original major release will overwrite the new or corrupt files. Just like in Windows 2000, running the CD installation will overwrite any new and corrupt files so you have a vanila system again.
I probably should also mention that I am using Microsoft .NET Setup and Deployments project to create the package.
[8|]
I probably should also mention that I am using Microsoft .NET Setup and Deployments project to create the package.
[8|]
Posted by:
TomB
19 years ago
Amccombs how are you planning on releasing the patches. I am guessing that this is an inhouse developed applicaiton and that you would also be createing the patches, is this correct?
How are you planning on deploying any patches? Would you use MSP files?
If so I would suggest that when you create the patches (MSP files) you look into using the MSI 3.0 patches because they have the ability to be uninstalled. This would allow for the user to uninstall the patch and to then repair the origional MSI if needed if a patch where to cause any issues with the system.
This would require that your users have at least Windows XP SP 2 or your install would need to install the 3.0 redistrib file.
This however is something that would require some bit of research on your part.
Most if not all documentation can be found on the MSI SDK link that WiseUser has provided above, but here is a link to the patching:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/patching.asp
How are you planning on deploying any patches? Would you use MSP files?
If so I would suggest that when you create the patches (MSP files) you look into using the MSI 3.0 patches because they have the ability to be uninstalled. This would allow for the user to uninstall the patch and to then repair the origional MSI if needed if a patch where to cause any issues with the system.
This would require that your users have at least Windows XP SP 2 or your install would need to install the 3.0 redistrib file.
This however is something that would require some bit of research on your part.
Most if not all documentation can be found on the MSI SDK link that WiseUser has provided above, but here is a link to the patching:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/patching.asp
Posted by:
WiseUser
19 years ago
ORIGINAL: amccombs
I am packaging a major release. If there are any patches released afterwords that mess up the system I want to make sure the original major release will overwrite the new or corrupt files. Just like in Windows 2000, running the CD installation will overwrite any new and corrupt files so you have a vanila system again.
I probably should also mention that I am using Microsoft .NET Setup and Deployments project to create the package.
[8|]
look into
Are these statements correct?
1) You want to restore the original file version even if a newer one has been installed (by a third party application or patch)?
2) You want the repair to occur automatically, without you having to initiate it with an "msiexec" command line (or from within your application)?
Posted by:
amccombs
19 years ago
TomB:
I am not sure how I plan to release any patches if needed. But during my experiments, uninstalling a patch deletes the file and does not restore the original file. I don't know what version MSI that MS .NET makes. I think the target machines will have Windows 2003 Server.
WiseUser:
1) Yes I want to restore or replace the file version even if a newer one has been installed, there is no third party applications, all these files are my own.
2) I don't need them to repair automatically, and I probably don't want that feature either.
I am not sure how I plan to release any patches if needed. But during my experiments, uninstalling a patch deletes the file and does not restore the original file. I don't know what version MSI that MS .NET makes. I think the target machines will have Windows 2003 Server.
WiseUser:
1) Yes I want to restore or replace the file version even if a newer one has been installed, there is no third party applications, all these files are my own.
2) I don't need them to repair automatically, and I probably don't want that feature either.
Posted by:
WiseUser
19 years ago
Slowly a picture is emerging...
I'm startnig to agree with TomB. The functionality you're looking for may be "removeable patches"?
If you're simply trying to upgrade your application on a regular basis whilst maintaining the ability to roll back to the previous version without a complete remove/reinstall, then follow TomB's advice.
Although the version of your MSI is important, the version of the installer engine on the client machines is MORE important.
I'm startnig to agree with TomB. The functionality you're looking for may be "removeable patches"?
If you're simply trying to upgrade your application on a regular basis whilst maintaining the ability to roll back to the previous version without a complete remove/reinstall, then follow TomB's advice.
Although the version of your MSI is important, the version of the installer engine on the client machines is MORE important.
Posted by:
TomB
19 years ago
If the file is has the same name and the patch has a file with a newer version an uninstall should remove the file. However, at that point you should still be able to repair the original install after uninstalling the patch and the original files will be reinstalled. Depending on if you have the key paths setup correctly then when you launch the application for the first time after the removal of the patch the application should do a self repair.
If you do not wish to utilize the new patching features in the MSI 3.0, then you can try to alter the file versions in the MSI tables directly.
For example, if your file has a file version of 4.5.6.7. You can edit the MSI in ORCA and go to the File table and in the Version column change the version number to 99.99.99.99. So long as the file is present a self repair will not take place (as discussed previously in this thread). If for some reason a file with a newer version overwrites your install file, you can manually do a repair either through the command line or add\remove programs and then your file will be reinstalled (so long as the file version is not greater than 99.99.99.99).
You can also do this for non versioned files, however you will want to put a language ID such as 1033 to pass validation.
However, a danger is if you released a patch that DID work and you wanted to keep it and a self repair is launched for what ever reason, those files will also be overwritten.
If you do not wish to utilize the new patching features in the MSI 3.0, then you can try to alter the file versions in the MSI tables directly.
For example, if your file has a file version of 4.5.6.7. You can edit the MSI in ORCA and go to the File table and in the Version column change the version number to 99.99.99.99. So long as the file is present a self repair will not take place (as discussed previously in this thread). If for some reason a file with a newer version overwrites your install file, you can manually do a repair either through the command line or add\remove programs and then your file will be reinstalled (so long as the file version is not greater than 99.99.99.99).
You can also do this for non versioned files, however you will want to put a language ID such as 1033 to pass validation.
However, a danger is if you released a patch that DID work and you wanted to keep it and a self repair is launched for what ever reason, those files will also be overwritten.
Posted by:
amccombs
19 years ago
Not really, I don't think I want removable patches, that's much too complicated which I have proven to be.
No more KISS days huh? [:(]
Quote from TomB's link
Note It is not possible to eliminate all circumstances when the application of a patch may require access to the original installation source.
That's not acceptable.
I remember tring to uninstall somthing and I did not have the msi that it can with. It was a pain to uninstall it.
No more KISS days huh? [:(]
Quote from TomB's link
Note It is not possible to eliminate all circumstances when the application of a patch may require access to the original installation source.
That's not acceptable.
I remember tring to uninstall somthing and I did not have the msi that it can with. It was a pain to uninstall it.
Posted by:
WiseUser
19 years ago
Posted by:
amccombs
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.