Deploy MSIs that Have No Advertised Entry Points
Once in a while, one has to repackage applications that have no advertised entry points (like shortcuts) but they need to install files in user profile locations or some specific user configuration. Here's how I do it.
When deploying such applications, everything is installed in System Context and all the user specific files and configuration info are missing. Because the application has no advertised entry points, there is nothing that might trigger the installation for any user. So, what do we do in this case? How can we make sure that those user-specific files & configuration info will be installed?
This issue can be solved in a number of ways. I will present two of them:
1. Using Active Setup registry keys.
These keys are used by Windows during the "just-in-time" setup process for user profiles. Windows creates a user profile for each new user and then runs the "just-in-time" setup process to finish configuring it.
The registry key "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components" drives this "just-in-time" setup process.
In case you didn't know it already, this is what Active Setup registry keys look like:
The "(Default)" entry stores the Application (or Component) Name, the "Version" entry stores the version of the application while the "StubPath" entry stores the command that needs to be executed by the "just-in-time" setup process.
During the "just-in-time" setup process, Windows reads all the entries in the "...Active Setup\Installed Components" tree and runs the commands stored in each "StubPath" key. If the "StubPath" entry is empty or missing, nothing is executed.
Each time a user logs in, Windows compares the
"HKLM\Software\Microsoft\Active Setup\Installed Components\[PRODUCTCODE]"
and
"HKCU\Software\Microsoft\Active Setup\Installed Components\[PRODUCTCODE]"
registry keys.
If the registry entries from HKCU do not exist or they have an inferior version number than those from HKLM, then the command stored in the "StubPath" entry is executed and the appropriate entries are created in HKCU.
One of the most elegant and simple solutions for repackaging and deploying applications that have no advertised entry points but require the installation of user files and registry keys is to include Active Setup registry keys in your package.
The only thing you need to do is add the appropriate entries in "HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\[ProductCode]".
Like you can see in the above screenshot you need to create just a few entries. The "StubPath" entry is extremely important and, if missing, nothing will be executed.
"StubPath" should have a string value such as "msiexec /fauvs {ProductCode} /qb".
After the package is deployed, when a user logs in, Windows will check the Active Setup registry entries and will notice that the application is not installed for the current user. In this case it will run the command line that will force the installation of the application for the user and all user files and registry keys will be installed in the appropriate locations. After that, Windows will generate the appropriate Active Setup registry entries for the installed application so the installation process won't be repeated at the next log in of the same user.
2. Using a VBScript.
You can also use the VBScript posted below.
You need to import this script into your MSI package and create an entry in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" that executes this script at every log on. The "Run" registry key should have a value like "wscript.exe [Path-to-script] {ProductCode}".
The script checks if the application is installed for the user that just logged in. If the application is not installed, it forces the installation of the application for that user.
The script also checks if there are any other MSI installations running at log in. If so, the script waits for them to finish and then starts doing its job. After the installation is finished, the script writes the key "HKCU\Software\[Application Name]\SelfHealing" with the value "true". Next time the same user logs in, the script checks if this key exists and if it does, it does nothing.
I hope these two solutions will be of help to you. If you have other solutions or suggestions, please feel free to post a comment.



Comments
Add HKCR keys as well
Nice article about Active Setup.
However, I'd recommend to add not only the HKLM keys to the package but the HKCR keys as well. This avoids that the user who has already installed the package gets a repair when he logs on to the workstation the next time.
Thanks duijsterj!
The problem mentioned has had me stumped for a while now, which is why I have always reverted back to RapidInstall in cases where HKCU needs to be updated for all user profiles (new and existing).
I used method 1 (Active Setup), and it worked beautifully. Now there's no need to go back to antiquated RapidInstall.
Thanks duijsterj!
msi current user repair
I do not agree with your commandline
msiexec /fauvs
"a" should be used with extreme caution. It writes the files in your MSI regardless of version. Any files that are in your application that are shared by others (like system files) will now be your version. An applications requirin a newer version might not now work
"v" is for recaching the MSI. This should only ever be used in a minor upgrade/update package
In your VBS you use /fup which I think is far more appropriate
looeee
Agree
I totally agree with your point here. option "a" can be used if you have only private copies of the files in your package and they are not getting replaced and you want a forced installation of your files.
This is generally used in extreme conditions.
msiexec /fups is a good option to try.
Piyush Nasa Altiris Certified Professional (ACP)
http://msiworld.blogspot.com/
Would you like to reply?
Login or Register to post your comment.