1

I wrote a simple function to test custom actions. I simply unzip a file to the directory.

The custom action is executed correct if I execute the msi with

msiexec /i MyProgramm.msi /l*v thelog.txt

But if I simply execute the msi with double click to install, the custom action is not executed

<Binary Id="CustomActions" SourceFile="$(var.CustomAction1.TargetDir)\$(var.CustomAction1.TargetName).CA.dll" />

        <CustomAction Id="UnzipFiles" BinaryKey="CustomActions" DllEntry="CustomAction1" Execute='immediate' Impersonate='no' Return="check"/>

        <InstallExecuteSequence>
            <Custom Action="UnzipFiles" After="InstallFinalize"></Custom>
        </InstallExecuteSequence>

This is using WiX 3.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Jens H
  • 105
  • 1
  • 10
  • Does your setup abort if you run it interactively? I would enable logging policy so there is always a log created for MSI installations - [see how here](https://stackoverflow.com/a/54458890/129130). Also: [How to debug custom actions](https://stackoverflow.com/questions/52878332/wixsharp-debug-custom-action-in-console/52880033#52880033). You can also find: [WiX resource links here](https://stackoverflow.com/questions/25004226/msi-vs-nuget-packages-which-are-is-better-for-continuous-delivery/25005864#25005864). – Stein Åsmul Nov 29 '21 at 23:25
  • Unzipping files as part of installation is not good practice, but I guess it is OK if it is just a custom action test for you. You can check out this example: https://github.com/glytzhkof/WiXCustomActionsTesting – Stein Åsmul Nov 29 '21 at 23:29
  • Short version for enabling global logging for all MSI files: http://www.installsite.org/pages/en/msifaq/a/1022.htm – Stein Åsmul Nov 30 '21 at 00:28
  • Hi @SteinÅsmul, No it does not abort, it runs correctly but without the custom action executed. Not sure if I understand the logging correctly. So the logging can be activated for if I just double click on the msi instead of running the cmd command with msiexec? – Jens H Nov 30 '21 at 02:17
  • I do have the think something is wrong with the wix configuration. System context vs user context. But not sure what is what and how to debug this part. – Jens H Nov 30 '21 at 02:21
  • See now the problem but not sure how to solve it. If the command line is run as administrator it works. If I run the command line normally it does not work. – Jens H Nov 30 '21 at 04:57

2 Answers2

0

Launch Condition: It is common to use a launch condition to check for admin rights when invoking an MSI installation:

<Condition Message="Administrator rights are required to install [ProductName].">
  <![CDATA[Privileged]]>
</Condition>

After injecting the above in your WiX source, you can test by invoking the install from a non-privileged cmd.exe window or by launching the MSI interactively whilst logged in as a standard user.

Silent Installation: For a properly silent installation there will be no interactive error message, but the condition message will show up in the MSI log file and the system's event log.

Invoke silent installation:

msiexec.exe /i MySetup.msi /qn

Custom Actions: Custom actions are known to cause all kinds of deployment problems. Here is a long tirade on the subject: Why is it a good idea to limit the use of custom actions in my WiX / MSI setups?


Limited User Setups: A digression. It is possible to make an MSI that can install for a user without admin rights. This is not recommended, but possible if you adhere to a number of restrictions within the package. Here is a sample: https://github.com/glytzhkof/WiXPerUserSample (not extensively tested). Notice the Package element and the two attributes: InstallScope and InstallPrivileges.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
0

Ok I had following problem.

I opened my command line as administrator.

So if I executed

msiexec /i MyProgramm.msi /l*v thelog.txt

I had more rights.

By opening up the command line normal, the log file showed me my problems with my action

Execute='deferred' Impersonate='no'
Jens H
  • 105
  • 1
  • 10
  • You should update your question with details like this and not add as an answer. What folders are you extracting to? Where are they located? In the user profile or under program files? Elevated rights are quite complicated to do right. It would be best to see the WiX source and the custom action source code. You need to send property values to deferred mode. Here is a sample: https://github.com/glytzhkof/WiXDeferredModeSample – Stein Åsmul Dec 02 '21 at 03:34