Steve Wellens
Steve Wellens

Reputation: 20640

Wix Custom Action works under Windows 8, Fails under Windows 7

I'm launching a custom action console application that can return 0 or -1.

On Windows 8 when it returns 0, the install continues.

On Windows 7 when it returns 0, the install ends prematurely.

<Property Id="QtExecCmdLine" Value="&quot;$(var.SourceFiles)\MyProgram.exe&quot;"/>
<CustomAction Id="CheckForOld" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
     <Custom Action="CheckForOld" After="AppSearch" />
</InstallExecuteSequence>

Does anyone know what can be done to resolve this?

Upvotes: 1

Views: 269

Answers (3)

Bogdan Mitrache
Bogdan Mitrache

Reputation: 11023

What are the UAC levels/settings on the Windows 8 and Window 7 machines? If you have UAC disabled on your dev machine but enabled (default setting) on the test Win 7 you could get the EXE failing to run as a custom action.

In this case I also recommend migrating your code to a DLL, you could write a C# DLL, using WixToolset and DTF. The DLL can then set a property with the result of this search, and you can use that property to define a new launch condition to stop the installation, if required.

From Tao of the Windows Installer, Part 5

Rule 53: Test thoroughly It is crucial that you test your packages thoroughly before deployment. A classic mistake is for developers and package authors to test only on their own systems where they have full administrator rights and then discover that normal users cannot use their applications.

Upvotes: 2

Christopher Painter
Christopher Painter

Reputation: 55601

What is this EXE supposed to do? There are several code smells. First is that it's scheduled in the UI sequence only. It won't get run during a silent install. The second is it's an EXE scheduled as immediate. EXE's can't access the MSI handle and set properties or do anything useful so I assume the EXE is changing the configuration of the machine. This is inappropriate outside of the execute sequence transaction. Finally, QtExecCmdLine needs an absolute path to the EXE on the destination machine. I don't see how $(var.SourceFiles) could provide that. That's a preprocessor variable that's only going to tell you where the file exists on the build server.

You aren't testing on your own dev machine? I'm guessing you build this on a Win 8 box and then tested on the same box. It happens to work cause it can find the file. When you run it on another machine (Win 7) it can't find the file and fails because the file can't possibly be there... you haven't installed anything yet.

Upvotes: 0

Stein &#197;smul
Stein &#197;smul

Reputation: 42226

Is that a QT exe file? What is the EXE file doing / checking? What happens if you turn off error checking - does it run and perform its task?

I wouldn't recommend to run a custom action with an exe file if you write the code yourself. Write it as a dll and connect the debugger to the code to step through it using a debug build dll - you will see exactly what happens as you step through the code:

  • Insert code to show a message box from within the function you want to debug
  • Compile a debug dll file and insert into the MSI file with the necessary plumbing to hook things up. This isn't entirely trivial, but not that complicated. See link below.
  • Run the MSI and wait for the message box to show
  • Attach the debugger to the correct msiexec.exe - either the user context one or the system context one depending on how your custom action is sequenced
  • Set breakpoints and step through the code to determine what is happening

How to create a basic MSI dll: http://www.codeproject.com/Articles/1747/MSI-Custom-Action-DLL

Upvotes: 0

Related Questions