Windows Installer and Self Repair

When an MSI based application starts, the primary executable isn’t actually run first. This is the secret of how MSI files use self-repair. The shortcuts for an MSI are known as Advertised shortcuts and they don’t point to an executable but instead point to GUID’s for an installed MSI. When you run an Advertised shortcut it calls the Windows Installer subsystem which will eventually call the executable for you. Before it calls the executable it checks to make sure all of the required files and Registry entries are present before starting the application.

Every component within an MSI has a “key” which is checked by the subsystem and verified as present before the application starts. The Window below shows that the “Key” for the comct332.ocx component is the file “comct332.ocx”. It’s important to remember that you choose where a component is installed to – not a file. Although a component may contain a number of files, they all must install to the same subdirectory. You might install a number of files with one component if they were likely to be changed and you didn’t want the altered files all repaired when the MSI started… as long as the file is a “key”, any changes will be automatically reverted when the application is started.

 

A component will try and group everything together for a particular file. If that file has COM entries, they will be associated with the same component, same as Registry entries.

If the key-file or registry entry is removed or altered, the whole component will be forced back again at application start-up.