Icerman
Icerman

Reputation: 1119

Install files to windows directory in WiX

I am trying to install some files to WindowsFolder. Here is the markup:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="MyAppSetup" Language="1033" Version="1.0.0.0" Manufacturer="abc" UpgradeCode="C313D73A-0FE5-496C-BD86-C21565BD65ED">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />

        <Feature Id="ProductFeature" Title="MyAppSetup" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="WindowsFolder">
                <Directory Id="INSTALLFOLDER" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
     <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component Id="myApp1" Guid="13B43FD7-8D69-4D2E-BF03-B3EC5679D78A">
        <File Id="myApp.pdb" Source="myApp64.pdb" KeyPath="yes" />
      </Component>
      <Component Id="myApp2" Guid="23B43FD7-8D69-4D2E-BF03-B3EC5679D78A">
        <File Id="myApp.sys" Source="myApp64.sys" KeyPath="yes" />
      </Component>
      <Component Id="myApp3" Guid="33B43FD7-8D69-4D2E-BF03-B3EC5679D78A">
        <File Id="myAppsvc.exe" Source="myAppsvc64.exe" KeyPath="yes" />
      </Component>
      <Component Id="myApp4" Guid="43B43FD7-8D69-4D2E-BF03-B3EC5679D78A">
        <File Id="myAppsvc.pdb" Source="myAppsvc64.pdb" KeyPath="yes" />
      </Component>
     </ComponentGroup>
    </Fragment>
</Wix>

Based on my reading, this directory element specifies the files to be installed/copied under WindowsFolder (on my machine C:\windows), but instead, it installs files to D:\ which has the most space. So the question is : what did I do wrong on the directory?

Upvotes: 0

Views: 2568

Answers (1)

Icerman
Icerman

Reputation: 1119

It turns out that the Directory reset happens when the msi is launched through msiexec using /a (admin) option. Here is a few log entries show this:

PROPERTY CHANGE: Adding TARGETDIR property. Its value is 'D:\'.
PROPERTY CHANGE: Modifying WindowsFolder property. Its current value is 'C:\windows\'. Its new value: 'D:\'.
PROPERTY CHANGE: Adding APPLICATIONROOTDIRECTORY property. Its value is 'D:\'.

If msi is launched using /i option, then the Directory reset is not happening. Since package needs to be installed with elevated privilege, the correct way to do this is using /i option in a elevated CMD console. The markup was never the issue.

Upvotes: 1

Related Questions