Dev
Dev

Reputation: 1020

How to run .reg files when running the msi?

I am trying to understand how my setup.msi inserts registry values when installing it. In Orca editor I am seeing like this,

enter image description here

After installing the msi, in the log file I am seeing like this,

MSI (s) (A8:B4) [16:27:28:674]: Executing op: ComponentRegister(ComponentId={45667B7F-9DC7-43B7-BE9E-3215ED1B1985},KeyPath=02:\SOFTWARE\myCompany\MySolution\Plugins\MyProduct\ProductCode,State=3,,Disk=1,SharedDllRefCount=0,BinaryType=0)

I want to do the reverse engineering of this mechanism, can any one help me to understand this? I want to recreate the same using WIX, so I just tried like below

 <Component Id="RegistryEntries" Guid="*">
            <RegistryKey Root="HKLM"
                         Key="Software\Microsoft\MyCompany"
                  Action="createAndRemoveOnUninstall">
              <RegistryValue Type="string" Name="MyApp" Value="[INSTALLLOCATION]" KeyPath="yes"/>
              <RegistryValue Type="string" Name="Configuration Files" Value="[INSTALLLOCATIONCONFIG]"/>
              <RegistryValue Type="string" Name="Configuration Files1" Value="[INSTALLLOCATIONCONFIG1]"/>
            </RegistryKey>
          </Component>

When I built the msi and if edit it Orca, I am seeing like below, enter image description here

What should I do to get the msi as shown in the previous image?

Upvotes: 1

Views: 2576

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55601

MSI expresses registry data in the Registry table. During the installation, the system determines which features and components are being installed therefore which registry adds, updates and deletes to perform. The actual work is carried out by the WriteRegistryValues and RemoveRegistryValues actions.

It is not a best practice to "execute a reg file" during an installation because it's out of process and MSI can't manage the changes. Instead use the WiX Heat tool to harvest the contents of the registry file into wix xml source for inclusion in your installer.

Upvotes: 5

Related Questions