[wix-users] Using the same installer for manual and administrative installs, allowing custom installdir overwrite.

Andreas Orzyszek andreas.orzyszek at gmail.com
Wed Feb 3 07:51:51 PST 2021


Hi,

in this case the property that must be set from the commandline should 
be INSTALLDIR=<FolderPath>

But you are using the /a option which is administrative install and this 
is maybe not what you want.

Try msiexec <msiFilePath> /quiet /norestart /l*v <LogFilePath> 
INSTALLDIR=<FolderPath>

And try it with your commandshell first before from the powershell 
script. You can then check the log for the INSTALLDIR Property.

Am 03.02.2021 um 15:06 schrieb Stefan Strijker via wix-users:
> Hello,
>
> I have got some software that is distributed trough an MSI installer. Everything seems to be working out fine as long as this installer is manually run. For testing purposes however, I am trying to run the same installer inside of our testing framework during setup, using msiexec
>
> ```
> string targetDirectory = @"C:\git\00_DATA\; // For testing purposes
> string arguments = "/qn /a \"" + msiFile + "\" TARGETDIR=\"" + targetDirectory + "\" /l*V \"" + logLocation + "\"";
> Directory.CreateDirectory(targetDirectory);
> Process process = Process.Start("msiexec", arguments);
> ```
>
> The MSI installer looks roughly like this:
> ```
> Product Id="*" Name="$(var.productName)" Language="1033" Version="$(var.productVersion)" Manufacturer="$(var.companyName)" UpgradeCode="$(var.productUpgradeCode)">
>      <!--package requires installer 400 (4.0. included from vista and up). install on machine scope-->
>      <Package Id="*" InstallerVersion="400" Compressed="yes" InstallScope="perMachine" />
>
>      <!--Require administartor access rights-->
>      <Condition Message="You need to be an administrator to install $(var.productName).">
>        Privileged
>      </Condition>
>
>      <!--Check if this is an update-->
>      <MajorUpgrade AllowSameVersionUpgrades="yes" Disallow="yes" DowngradeErrorMessage="A later version of the package is already installed. Setup will now exit." DisallowUpgradeErrorMessage="Please uninstall the  package using the control panel before installing a newer version."/>
>
>      <!--Enforce all resources to be dumped into a cab file, enabled very light compression to save on speed but take easy shortcuts to make it a little smaller-->
>     <Media Id="1" Cabinet="data.cab" EmbedCab="yes" CompressionLevel="mszip"/>
>
>      <!--Directory structure for installation, root-->
>      <Directory Id="TARGETDIR" Name="SourceDir">
>        <Directory Id="$(var.programFolder)">
>          <Directory Id="$(var.companyName)" Name="$(var.companyName)">
>            <Directory Id="INSTALLDIR" Name="$(var.ProductName)">
>
>              <!--Add installation directory as component. This way it will clean up all of the module in one go, instead of having to set a delete on every single file-->
>              <Component Id="INSTALLDIR_comp" Guid="920C1EF1-DFAA-43FB-84A6-FA50EC0AD661">
>                <CreateFolder>
>                  <Permission User="Users" GenericAll="yes" />
>                </CreateFolder>
>              </Component>
>
>            </Directory>
>          </Directory>
>        </Directory>
>      </Directory>
>
>      <!--Feaatures are 'what to install'. Only support a full install for now-->
>      <Feature Id="Complete" Title="$(var.productName)" Description="Full installation" Display="expand" Level="1" ConfigurableDirectory="INSTALLDIR">
>        <ComponentRef Id="INSTALLDIR_comp"/>
>        <ComponentRef Id="Product_Component"/>
>        <ComponentGroupRef Id="INSTALLDIR_comp"/>
>      </Feature>
>
>      <!--Set pictures, banners ect for screen-->
>      <WixVariable Id="WixUIBannerBmp" Value="banner.bmp" />
>      <WixVariable Id="WixUIDialogBmp" Value="dialog.bmp"/>
>
>      <!--Set programs and installer icon-->
>      <Icon Id="installer_icon" SourceFile="installer.ico"/>
>      <Property Id="ARPPRODUCTICON" Value="installer_icon"/>
>
>      <!--Property with installation folder location (from and to ui)-->
>      <Property Id="WIXUI_INSTALLDIR">INSTALLDIR</Property>
>
>      <!-- Variable with the location of the license -->
>      <WixVariable Id="WixUILicenseRtf" Value="license.rtf" />
>
>      <!--UI-->
>      <UI>
>        <UIRef Id="WixUI_InstallDir" />
>        <UIRef Id="WixUI_ErrorProgressText" />
>      </UI>
>    </Product>
> </Wix>
> ```
>
> When manually ran the installdir dialog allows me to overwrite the INSTALDIR just fine, providing the
> programfiles/<companyname>/<productname> location as a default.
>
> When ran trough msiexec however, INSTALLDIR doesnt seem to be working as a valid parameter, causing me to not be able to overwrite it causing it to always end up in the default location: programfiles/<companyname>/<productname>
> .
>
>
> As an alternative I have received the suggestion to replace the <Directory> bit with the following:
> ```
> <!-- Set the installdir after the launchconditions, we have to this otherwise the installdir has subdirs when doing an administrative install (no launch conditions event in administrative install).-->
> <SetProperty Id="INSTALLDIR" After="LaunchConditions" Value="[$(var.programFolder)]\$(var.companyName)\$(var.productName)"/>
>
> <!--Directory structure for installation, root-->
> <Directory Id="TARGETDIR" Name="SourceDir">
> <Directory Id="$(var.programFolder)">
> <Directory Id="INSTALLDIR">
> ```
>
> This fixes the issues I have with msiexec, allowing me to specify the location to install with the TARGETDIR parameter. However, the wix_UI bit no longer seems to overwrite anything in manual instalation with this change.
>
> After having struggled with this for a full day trying out different solutions (adding custom parameter to overwrite installdir in a customaction and other attempts), I figured I should go to the great internet and ask for help :)
>
> Can anyone here point me in the right direction and give me some guidance ? Or even provide a working example/snippet that allows me to use 1 and the same installer for manual use + msiexec usage, while still being able to provide a default location in case nothing is specified in parameters.
>
> Thanks,
> Stefan Strijker
>
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list