wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 36 forks source link

When using the MSI internal UI bootstrapper application (wixiuiba), the MSI internal UI appears behind other windows #7874

Open cstavaru opened 11 months ago

cstavaru commented 11 months ago

4.0.3

Visual Studio 2022 Community Edition 17.8.0

HeatWave Community Edition 1.0.2

6.0

Windows 11 version 22H2

I am trying to use the bal:WixInternalUIBootstrapperApplication to build a simple exe bundle with one test package. The test package uses the WixUI_Advanced UI. When double-clicking the bundle in Windows Explorer, the MSI internal UI appears immediately behind the Explorer window but on top of other windows, giving the impression that the installation did not actually start. If I alter the package and build it with a per-machine scope, the UAC prompt appears blinking in taskbar.

When clicking the bundle executable in Windows Explorer, the MSI internal UI appears in foreground and visible. On a per-machine installation, the UAC prompt appears in foreground and not blinking in taskbar.

Thanks !

chrpai commented 10 months ago

If I remember correctly, this is solved if you add a splash screen to the bootstrapper. It appears to be a windows behavior when a process has no active UI when elevation is requested. For the reason I automatically include a tiny 1 pixel splash to the relevant project templates in IsWiX.

cstavaru commented 10 months ago

If I remember correctly, this is solved if you add a splash screen to the bootstrapper. It appears to be a windows behavior when a process has no active UI when elevation is requested. For the reason I automatically include a tiny 1 pixel splash to the relevant project templates in IsWiX.

Thanks for the insightful reply. I just checked the element and I can set a theme and a logo (which I do, I set the "standard" theme and my company logo). The resulting bundle does briefly display a window when clicking on it but then it closes and the internal UI still appears behind.

Maybe the problem is that the splash window closes before the MSI internal UI appears ? I don't seem to be able to have control over that behavior.

chrpai commented 10 months ago

I just retested my templates by creating a new IsWiX Bundle - InternalUI (WiX v4) project. It worked correctly with UAC appearing up front and then the MSI UI appearing up front. The bundle wxs looks like:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
  <Bundle Name="ProductName1" Version="$(var.MSIProductVersion)" Manufacturer="ProductName1" UpgradeCode="2736d2d7-8a12-458e-96bf-02e1ea481f16" SplashScreenSourceFile="Resources\splash.bmp">
    <BootstrapperApplication>
      <bal:WixInternalUIBootstrapperApplication LogoFile="Resources\Icon.png" Theme="standard" ThemeFile="Resources\iuipreq.thm" LocalizationFile="Resources\iuipreq.wxl"/>
    </BootstrapperApplication>
     <Variable Name="InstallFolder" bal:Overridable="yes" Type="formatted" Value=""/>
    <Chain>
            <PackageGroupRef Id="NetFx48WebAsPrereq"/>
      <MsiPackage Id="ProductName1" SourceFile="$(var.ProductName1Package.TargetPath)">
        <MsiProperty Name="INSTALLLOCATION" Value="[InstallFolder]"/>
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix>
cstavaru commented 10 months ago

I just retested my templates by creating a new IsWiX Bundle - InternalUI (WiX v4) project. It worked correctly with UAC appearing up front and then the MSI UI appearing up front. The bundle wxs looks like:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
  <Bundle Name="ProductName1" Version="$(var.MSIProductVersion)" Manufacturer="ProductName1" UpgradeCode="2736d2d7-8a12-458e-96bf-02e1ea481f16" SplashScreenSourceFile="Resources\splash.bmp">
    <BootstrapperApplication>
      <bal:WixInternalUIBootstrapperApplication LogoFile="Resources\Icon.png" Theme="standard" ThemeFile="Resources\iuipreq.thm" LocalizationFile="Resources\iuipreq.wxl"/>
    </BootstrapperApplication>
     <Variable Name="InstallFolder" bal:Overridable="yes" Type="formatted" Value=""/>
    <Chain>
          <PackageGroupRef Id="NetFx48WebAsPrereq"/>
      <MsiPackage Id="ProductName1" SourceFile="$(var.ProductName1Package.TargetPath)">
        <MsiProperty Name="INSTALLLOCATION" Value="[InstallFolder]"/>
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix>

I have used your file exactly and I still get the initial described behavior. I will try with the IsWix project to see if that is still the case. Do you use Windows 11 ? Maybe there is something changed compared to Windows 10.

cstavaru commented 10 months ago

@chrpai I just created a new project using the IsWiX addon for VS2022 (v5.0.49.0) and the behavior is still like initially described. I used the "IsWiX Bundle - InternalIUI (Wix v4)" project template. I first just built the template as it was and the UAC prompt appears in taskbar, and then I set the MSI Scope to "perUser" and the internal MSI UI appears behind the Explorer windows.

Any solution or idea would be much appreaciated.

chrpai commented 10 months ago

Well that's a pisser. I thought this workaround was good to go. My testing has been on Windows 11. Currently 23H2. #7394 and #7379 are related issues.

cstavaru commented 10 months ago

@chrpai (and whoever is interested) I think I know what the problem is.

I noticed that in internal bootstrapper application, the splash screen window is closed before the MSI installation is started, in method CWixInternalUIBootstrapperApplication::OnExecuteBegin(). When I simply commented the line that closes the splash screen and rebuilt everything, the MSI UI is displayed correctly (but of course the splash screen remains on screen).

One solution that I see is to close the splash screen on some callback called by MSI after it displays its internal UI (if this is at all possible) for example maybe MsiSetExternalUI provides an opportunity to close the splash screen on some message that the user is called with at the beginning of the installation process (looking at the MSI API, the INSTALLMESSAGE_INITIALIZE would appear to be a good place to close the splash screen).

Another solution is to start a timer in OnExecuteBegin and close the splash screen after a short delay, like 0.5-1 second.

And finally the least desirable solution is to use a 1 pixel splash screen and simply leave that line commented and not close it until the installation finishes :) (just tested this and it works well).

I will continue to familiarize with the Wix Toolset source code and see if I can find an elegant solution.

chrpai commented 10 months ago

@cstavaru nice observations.

BTW, feel free to checkout https://github.com/iswix-llc/iswix-tutorials and email me if you have any questions.