Register a COM library without copying exe file to the installation directory and execute custom action before registering it

46 views Asked by At

In my WiX project I have below fragment in one of my MyCOMObject.wxs files:

  <Fragment>
    <Feature Id="MyCOMObject"
             Title="My COM Object"
             AllowAdvertise="no"
             Display="hidden"
             Level="1">
      <ComponentGroupRef Id="COMObjectComponent" />
      <ComponentRef Id="RegisterMyCOMObjectToRunAtStartUp"/>
      <Condition Level="0">
        <![CDATA[REMOVE AND (NOT UPGRADINGPRODUCTCODE)]]>
      </Condition>
    </Feature>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="COMObjectComponent"
                    Directory="APPLICATIONFOLDER">
      <Component Id="myCOMObject.lib"
                 Guid="{AB4304B8-C9BA-49C7-5423-112CB1210000}">
        <File Id="myCOMObject.exe"
              KeyPath="yes"
              Source="$(var.myCOMDir)\myCOMObject.exe">
          <TypeLib Id="{86000350-400E-00F1-00DF-6F00F0CD0BBC}"
                   Description="myCOMObjectLib"
                   HelpDirectory="APPLICATIONFOLDER"
                   Language="0"
                   MajorVersion="1"
                   MinorVersion="0"
                   Advertise="yes">
            <Class Id="{4326682B-657B-4DFE-A68D-47252874C000}"
                   Context="LocalServer32"
                   Description="myCOMObject Class"
                   ThreadingModel="apartment"
                   Version="1.0" />
            <Interface Id="{225E49AF-4575-4876-A53B-81A5AB281111}"
                       Name="ImyCOMObject"
                       ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
            <Interface Id="{24592647-A858-5555-B01F-BE4DCB8C86A1}"
                       Name="ImyCOMObjectCallbacks"
                       ProxyStubClassId32="{11120424-1111-0000-C000-000000000046}" />
          </TypeLib>
        </File>
      </Component>
    </ComponentGroup>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="TARGETDIR">

      <!-- Registers my COM Server object so it can be run at each startup -->
      <Component Id="RegisterMyCOMObjectToRunAtStartUp"
                 Guid="*">
        <RegistryValue Id="MyCOMObjectToRunAtStartUp"
                       Root="HKMU"
                       Action="write"
                       Key="Software\Microsoft\Windows\CurrentVersion\Run"
                       Name="myCOMObject.exe"
                       Value="[APPLICATIONFOLDER]myCOMObject.exe"
                       Type="string" />
      </Component>

    </DirectoryRef>
  </Fragment>

Then in my Product.wxs file I reference it as below within the Product section:

<Product>
    <FeatureRef Id="MyCOMObject"/>

    <CustomAction Id="MyCustomAction"
                  Return="check"
                  Execute="deferred"
                  Impersonate="no"
                  BinaryKey="CustomActions.CA.dll"
                  DllEntry="GetMyFileFromServer" />

    <InstallExecuteSequence>
        <Custom Action="MyCustomAction"
                Before="InstallFiles"><![CDATA[NOT Installed OR (Installed AND (NOT REMOVE="ALL" OR UPGRADINGPRODUCTCODE)) OR (REINSTALL<>"" AND NOT REMOVE="ALL")]]></Custom>

    </InstallExecuteSequence>
</Product>

I have two problems here that I am trying to resolve:

  1. The file myCOMObject.exe is being copied to the installation folder of my application and I don't want the exe file to be copied there. This file is copied through a through a custom action that connects to a remote server and downloads it.
  2. How can I execute my custom action MyCustomAction before the above piece of code in MyCOMObject.wxs gets executed? i mean, before the COM library is registered in the system, before RegisterMyCOMObjectToRunAtStartUp.
0

There are 0 answers