Hello fellow packagers — ever have an issue with trying to get a program to lay down the HKEY_CURRENT_USER (HKCU) keys? Well, let’s break down how to fix this issue. I am going to show you how to set up Active Setup within your applications MSI/MST file in order to have this HKCU stay on the machine, no matter how many users log into the system.
Active Setup helps to lay down Current User data when an application is deployed or even installed straight from the MSI itself. Active Setup can be set to do a repair and check for the current user keys that the application needs in order to fully run right. I am going to show this process, as its one of the most common processes to use with Active Setup.
Windows has keys that it will look for before it kicks off the full install of the MSI. These keys can be found under:
HKLMSoftwareMicrosoftActive SetupInstalled Components<UID>
…and also under:
HKCUSoftwareMicrosoftActive SetupInstalled Components<UID>
The <UID> should be unique, based off the application you’re using. Now, the best value to use for the <UID> would be the Globally Unique IDentifier (GUID); I suggest using the Product Code for the GUID. There are many options you can use for the GUID, but for this example I am going to use the Product Code for the application. This Code can be found in AdminStudio in a few locations: General Information, Property Manager or Direct Editor->Property table (these locations might be a little different depending on your packaging tool). Most packaging tools will still have a Property table where you can find the Product Code. Make sure to write down the GUID you will be using, as we will need this information later on.
So let’s take a deeper look into this process, in order to make these keys no longer an issue. Let’s begin by opening the MSI we would like to edit. You can also use a MST transform file if you are working with a vendor MSI.
Once the application is open you will want to navigate to the Registry section of your MSI/MST. When you are in the Registry section of your MSI/MST, navigate to:
Under the Microsoft folder, right click the folder and select New and make a new Key, in order to make a new folder under Microsoft. We will label this folder “Active Setup”.
You might be saying “Hey, I don’t have a Software folder under HKLM”… This is fine, it just means we need to make one. It’s easy as pie; you would make the parent folders the same way we did with the “Active Setup” Folder. Just make sure you build the folder structure as indicated above.
We need to set up two more folders the same way we did with our “Active Setup” folder. This time, however, we will name the first folder “Installed Components”, under the “Active Setup” folder. Under the new “Installed Components” folder, make another folder and label it “ProductCode”.
Once we have all our folders set up we need to make a “New string Value” under our “ProductCode” folder. To do this you can right click on the “ProductCode” folder and you will see the option “New string Value” under the drop down list. We are going to label our “New string Value” as “StubPath” (Windows will run anything under the “StubPath” whenever there is a command under it). If the current user key is already on the system, msiexec will not run the repair again because the key is already in the location it should be.
When you have your “StubPath” string created, double click it; we need to make some changes to the values in this string. You will see the Edit Data box come up; in this box we are going to use the following commands in the Value Data field:
Msiexec /fu (ProductCode or GUID) /qn
These are what the switches are doing that you are adding to the msiexec:
/f – Repair
/u – all required user-specific registry entries
/qn – Silent mode with no UI.
(For other repair options and switches I have added a link to Microsoft’s “msiexec” page: http://technet.microsoft.com/en-us/library/cc759262%28v=ws.10%29.aspx)
This new key will run once the application is launched. Make sure to test your application out, and check those keys you have made. The best way to check the MSI/MST is to launch the MSI/MST though the command line.
I hope this helps to clear up and issues with Current User key, and gives you a better understanding on how to fix the issue.