Good morning,
I am looking to achieve an external handler for msiexec, but not stopping msiexec from acting any different. I would like to be able to intercept all messages utilising the MsiSetExternalUI but still having the same responses and dialogs to the end user.
My main aim is intercept where the cached source for msi are installed from and move them to another location.
I have tried utilising logging utilise the logging registry key, but source location of packages can get deleted and the source of the package will not exist by the time i have intercepted the log file and got the location of the msi.
For example embedded msi in a setup exe especially old C++ redistributable extract themselves with the redist to a random directory on the root of the homedrive and install, then on completion delete the directory. The behaviour of msiexec isn't consistent as majority of packages are cached in the windows installer dir c:\windows\installer and the original packages cached in the c:\programdata\cached packages.
Why are some packages cached and others arent?
Hence the reason why i would like to utilise the External UI, but ensure that the behaviour is kept the same.
I am currently testing a project with
MsiInterop.MsiSetExternalUI(new MsiInstallUIHandler(_OnExternalUI), MsiInstallLogMode.ExternalUI, IntPtr.Zero);
Any ideas or examples would be really helpful.
I cannot see why intercepting the UI has anything to do with cache locations that you cannot alter while the install is in progress. However it's not clear exactly what usage of "cache" you are intending here. I'll assume that you are referring to the complete MSI file which may have been extracted to some location for install, or is otherwise at the location it was installed from.
Let's assume that the install has finished and you know (or can get) its ProductCode. All you need do to obtain all the official source locations is call MsiSourceListEnumSources () and that will tell you the actual locations that Windows will use to find the MSI for maintenance, upgrade, repair, etc, if and when required.
If the source MSI is at a location you do not approve of, then use MsiSourceListClearSource () to delete that entry, copy the MSI to a location of your choice, then use MsiSourceListAddSource () to add that location. There are plenty of sourcelist APIs for exactly this type of management activity, such as when products were installed from network locations that are no longer available.
I don't believe you should be moving or altering the internal cached (obfuscated name) MSI file that is typically in \windows\installer. That us sometimes referred to as the cached location, but you seem to be referring to the complete MSI used to install the product.