1
votes

This is my first crack at writing MSI installer. There's numerous posts here and elsewhere for custom commands in a WIX installer regarding UAC. Haven't found any that solve my issue, however.

I need to launch an app elevated in my MSI. I'm attempting to launch a .NET app (compiled to run as Admin) that will install a device driver. I use the .NET exe to display a 'connect device' prompt to the user if needed, then perform the actual driver install in unmanaged code.

The MSI immediately causes a UAC prompt, but the app then launches without elevation, and fails. Running from an elevated command prompt doesn't help. I read somewhere that adding the manifest to the install may help... it doesn't.

Here's my WIX code:

<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
   <Product Id="*" UpgradeCode="12345678-1234-1234-1234-111111111111" 
            Name="FlashBoot Driver" Version="0.0.1" Manufacturer="ACME Corp" Language="1033">
      <Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/>
      <Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>

      <Directory Id="TARGETDIR" Name="SourceDir">
         <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLDIR" Name="FlashBoot Driver">
               <Component Id="AppFiles" Guid="12345678-1234-1234-1234-222222222222">
                  <File Id="AppFile1" Source="C:\App\Release\Setup.exe"/>
                  <File Id="AppFile2" Source="C:\App\Release\Setup.exe.manifest"/>
                  <File Id="AppFile3" Source="C:\App\Release\Unmanaged.dll"/>
               </Component>
            </Directory>
         </Directory>
      </Directory>

      <Feature Id="DefaultFeature" Level="1">
         <ComponentRef Id="AppFiles"/>
      </Feature>

      <CustomAction Id="OurAction" 
                    Execute="deferred" 
                    Impersonate="no" 
                    Return="ignore" 
                    FileKey="AppFile1" 
                    ExeCommand="" />

      <InstallExecuteSequence>
         <Custom Action="OurAction" Before="InstallFinalize" />
      </InstallExecuteSequence>

   </Product>
</Wix>
1

1 Answers

0
votes

I resolved this by having the WIX installer launch a satellite app, which in turn launches the driver installer. The new app does not require elevation, while the driver installer does require elevation. An added benefit is that the new app can determine if it needs to run the 32 or 64bit version of the driver installer.

It still would be nice to know if there's a way to launch an app requiring elevation directly from the WIX installer though.