Reputation: 3022
I am trying to create a dual purpose MSI file using WiX. I have followed the instructions for WixUI_Advanced as well as the instructions for Single Package Authoring. This seems to work fine when I default to having a per user install by default (MSIINSTALLPERUSER
= 1) and allow the user to select a per machine install. However setting it to install per machine by default (MSIINSTALLPERUSER
empty) always results in a UAC prompt even when the user selects a per user install. The per user install is only writing a single file to a non admin directory and definitely does not require elevated privileges.
I have also tried following this guide which everyone seems to be using to do Single Package Authoring with WiX but the results are exactly the same. A UAC prompt appears if per machine is the default and per user is selected but not if per user is the default and per user is selected.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="DE75C3B3-6398-4F25-9048-FB7EEE5F6EBF" Name="MyApp" Language="1033" Version="1.0.0" Manufacturer="Company" UpgradeCode="ED573078-CC3E-4299-9E04-043B1EDC08DB">
<Package InstallerVersion="500" Compressed="yes" />
<!--Single Package Authoring-->
<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="{}"/>
<Property Id="ALLUSERS" Secure="yes" Value="2"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" CabinetTemplate="arc{0}" CompressionLevel="high"/>
<Feature Id="ProductFeature" Title="MyApp" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<UI>
<UIRef Id="WixUI_Advanced" />
</UI>
<Property Id="ApplicationFolderName" Value="MyApp" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder" Name="PFiles">
<Directory Id="APPLICATIONFOLDER" Name="MyApp">
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
<Component Id="MyApp.exe" Guid="903EDAFD-F513-407D-85A0-D737013B9B57">
<File Id="MyApp.exe" Source="MyApp.exe" KeyPath="yes" Checksum="yes"/>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Looking through the install log I see the following entries:
Product not registered: beginning first-time install
PROPERTY CHANGE: Modifying ALLUSERS property. Its current value is '2'. Its new value: '1'.
PROPERTY CHANGE: Deleting MSIINSTALLPERUSER property. Its current value is '{}'.
...
Action: InstallScopeDlg. Dialog created
PROPERTY CHANGE: Modifying WixAppFolder property. Its current value is 'WixPerMachineFolder'. Its new value: 'WixPerUserFolder'.
PROPERTY CHANGE: Deleting ALLUSERS property. Its current value is '1'.
...
Product not registered: beginning first-time install
PROPERTY CHANGE: Deleting ALLUSERS property. Its current value is '2'.
PROPERTY CHANGE: Deleting MSIINSTALLPERUSER property. Its current value is '{}'.
Upvotes: 3
Views: 1844
Reputation: 71
There are three properties to control the default install scope when using WixUI_Advanced UI: 'ALLUSERS', 'Privileged' and 'MSIINSTALLPERUSER'.
The property 'WixAppFolder' will control which radio button is selected by default when 'advanced' button is clicked.
And there is a konwn bug of wix needs a workaround: https://github.com/wixtoolset/issues/issues/2376
In summary, the wix config can be:
Per user
<Property Id='WixAppFolder' Value='WixPerUserFolder' />
<Property Id='ALLUSERS' Value='2' />
<Property Id='Privileged' Value='0' />
<Property Id='MSIINSTALLPERUSER' Value='1' />
<UI>
<UIRef Id='WixUI_Advanced' />
<UIRef Id='WixUI_ErrorProgressText' />
<Publish Dialog='InstallScopeDlg' Control='Next' Property='MSIINSTALLPERUSER' Value='1' Order='3'>WixAppFolder = "WixPerUserFolder"
<Publish Dialog='InstallScopeDlg' Control='Next' Property='MSIINSTALLPERUSER' Value='{}' Order='2'>WixAppFolder = "WixPerMachineFolder"
<Publish Dialog='InstallScopeDlg' Control='Next' Event='DoAction' Value='WixSetDefaultPerMachineFolder' Order='3'>WixAppFolder = "WixPerMachineFolder"
<Publish Dialog='InstallScopeDlg' Control='Next' Event='DoAction' Value='WixSetDefaultPerUserFolder' Order='3'>WixAppFolder = "WixPerUserFolder"
</UI>
Per machine
<Property Id='WixAppFolder' Value='WixPerMachineFolder' />
<Property Id='ALLUSERS' Value='1' />
<Property Id='Privileged' Value='1' />
<Property Id='MSIINSTALLPERUSER' Value='0' />
<UI>
<UIRef Id='WixUI_Advanced' />
<UIRef Id='WixUI_ErrorProgressText' />
<Publish Dialog='InstallScopeDlg' Control='Next' Property='MSIINSTALLPERUSER' Value='1' Order='3'>WixAppFolder = "WixPerUserFolder"
<Publish Dialog='InstallScopeDlg' Control='Next' Property='MSIINSTALLPERUSER' Value='{}' Order='2'>WixAppFolder = "WixPerMachineFolder"
<Publish Dialog='InstallScopeDlg' Control='Next' Event='DoAction' Value='WixSetDefaultPerMachineFolder' Order='3'>WixAppFolder = "WixPerMachineFolder"
<Publish Dialog='InstallScopeDlg' Control='Next' Event='DoAction' Value='WixSetDefaultPerUserFolder' Order='3'>WixAppFolder = "WixPerUserFolder"
</UI>
BTW, I created a project to simplify the configuration of wix. Hope it can help: https://github.com/xinnj/WiXCover
Upvotes: 1
Reputation: 3022
Based on the install log I tried reintroducing the lines replaced in the modified WixUI file from this guide which update the ALLUSERS
property as it seems as though this was being set to a value of 1 for the per user install which would explain the UAC prompt. Having both the following lines from the Russian blog and the original WixUI_Advanced does seem to work.
<Publish Dialog="InstallScopeDlg" Control="Next" Property="ALLUSERS" Value="{}" Order="2">
WixAppFolder = "WixPerUserFolder"
</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="ALLUSERS" Value="1" Order="3">
WixAppFolder = "WixPerMachineFolder"
</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1" Order="3">
WixAppFolder = "WixPerUserFolder"
</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="{}" Order="2">
WixAppFolder = "WixPerMachineFolder"
</Publish>
It seems as though both ALLUSERS
and MSIINSTALLPERUSER
needs to be set based on the user's choice to allow installation with no Administrator privileges when a per machine install is the default. I can't find anywhere else online to confirm my findings however.
Upvotes: 3