Question

When I run my installer I get the following issue.

error

I'm doing some custom actions which require to access the registry and I can only think that its because the WiX configuration doesn't make it request admin priveleges. I've looked at some posts on SO and tried to use.

InstallPriveleges="elevated" 

within the package element however this does not make the installer have the admin shield nor request it therefore still producing the error.

Extra information about test project.

The name of my application is :WindowsFormsApplication33, the name of the custom action project is CustomAction1 and name of the Setup project is SetupProject1.

This is my current wix xml file.

    <Package InstallerVersion="200" Compressed="yes" InstallPrivileges="elevated" InstallScope="perUser" />

<Binary Id="CustomAction1.CA.dll" SourceFile ="..\CustomAction1\bin\$(var.Configuration)\CustomAction1.CA.dll" />
<CustomAction Id="disableTaskManager"
              Return="check"
              Execute="immediate"
              BinaryKey="CustomAction1.CA.dll"
              DllEntry="disableTaskManager" />

<CustomAction Id="enableTaskManager"
              Return="check"
              Execute="immediate"
              BinaryKey="CustomAction1.CA.dll"
              DllEntry="enableTaskManager" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <MediaTemplate />

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>


<InstallExecuteSequence>
  <Custom Action="disableTaskManager" Before="InstallFinalize"  />
  <Custom Action="enableTaskManager" After="InstallInitialize"><![CDATA[(NOT UPGRADINGPRODUCTCODE)]]></Custom>
</InstallExecuteSequence>

</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="Form Test Application" />
        </Directory>
    </Directory>
</Fragment>


<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <Component Guid="{EDA315F6-A115-4348-8607-981C252EA317}">
  <File Source="$(var.WindowsFormsApplication33.TargetPath)" KeyPath ="yes" />
  </Component>
  <Component Guid="{E3182F61-F563-4C13-82B5-8CC39D9DB380}">
    <File Source="$(var.CustomAction1.TargetPath)" KeyPath ="yes" />
  </Component>
  <Component Guid="{E4AF325E-B244-47F5-855A-5B40DBC425D2}">
    <File Source="..\WindowsFormsApplication33\bin\Release\WindowsFormsApplication33.exe.config" KeyPath="yes" />
  </Component>
    </ComponentGroup>
</Fragment>

Update : changing the InstallScope value from perUser to "perMachine" does make a UAC prompt however the DLL error still exists..

Was it helpful?

Solution 2

I struggled to get rid of the dll error however an alternative I found was to NOT use Custom Action and use the XML in the wix file to create the registry and then delete the key when uninstalling via the use of :

ForceDeleteOnUninstall="yes"

You have to use this in the

Example :

<!-- Register windows autostart registry -->
   <Component Id="RegistryEntries" Guid="45C7AC46-1101-4301-83E1-D24392283A60">
      <RegistryValue Type="string"
               Name="FooStartup"
               Value="[#FooMainApp]"
               Root="HKLM"
               Key="Software\Microsoft\Windows\CurrentVersion\Run"
               Action="write"/>
   </Component>

As found on : Registry change upon installing application C#

I really hope this helps someone new to WiX as it did to me.

OTHER TIPS

Your custom action is immediate, that means it will not run with elevation. It must be deferred to run with elevation. It's got nothing to do with WiX particularly, it's just that immediate custom actions run as the user but limited.

Use these three attributes inside custom action tag.

<CustomAction ....
Execute="deferred" 
Impersonate="no" 
Return="ignore" />

These fields will make the custom action to run with admin priveleges.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top