0

I'm trying to copy a few files into the C:\Windows\System32 folder (and C:\Windows\SysWOW64 respectively) in a simple WIX setup using the SystemFolder variable. However, it always seems to resolve to a weird path I'm not even having the slightest idea where MSI is getting that from.

Basically, SystemFolder resolves to the following: E:\SystemFolder\ (no, that's not a variable, the folder is actually called SystemFolder).


Edit

Alright, it seems that the variable isn't really resolved at all. I don't know where MSI is getting the E:\ from, but as soon as I alias $(var.WindowsSystemFolder), the correctly resolved variable SystemFolder becomes just SystemFolder (plain text), which isn't further processed. Help. :S


Variables.wxi (excerpt)

<!-- Platform Configuration -->
<?if $(var.Platform) = x64 ?>
<?define WindowsSystemFolder = "System64Folder" ?>
<?else ?>
<?define WindowsSystemFolder = "SystemFolder" ?>
<?endif ?>

Product.wsx (excerpt)

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="WINSYSTEMFOLDER" Name="$(var.WindowsSystemFolder)" />
</Directory>

somewhere.wsx

<Fragment>
  <DirectoryRef Id="WINSYSTEMFOLDER">
    <Component Id="RandomComponent" Guid="7784D238-2502-45B4-B5B3-180D31E56485">
      <File Id="RandomFile"
        Name="$(var.MyProject.TargetFileName)"
        Source="$(var.MyProject.TargetPath)" />

Flags passed to candle

-dDebug -dPlatform=x86 -arch x86
artganify
  • 683
  • 1
  • 8
  • 23

2 Answers2

0

The value E:\SystemFolder is coming from the combination of TARGETDIR (which is evaluating to the same as ROOTDRIVE, which is in turn the drive in the system with the largest amount of free space), and the literal text SystemFolder or System64Folder. This is because the Name attribute defines a path, not a reference to a predefined system folder.

Per How To: Add a File To Your Installer, you can put system folder properties in the Id attribute. If you want to give them an alternate Id that you can reference without the variable notation, create a directory beneath it with no Name (or possibly Name='.'). For instance, this modification to your Product.wsx excerpt may work (I haven't tested):

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="$(var.WindowsSystemFolder)">
    <Directory Id="WINSYSTEMFOLDER"/>
  </Directory>
</Directory>
Michael Urman
  • 15,737
  • 2
  • 28
  • 44
0

You'll need to run your .msi with logging, to find out where it is actually going to.

The system folder seems... special. In my log file it shows this:

Property(S): System64Folder = C:\WINDOWS\system32\
Property(S): SystemFolder = C:\WINDOWS\SysWOW64\
Property(S): System32Folder = C:\

Which of course makes no sense but that's what is happening.

john k
  • 6,268
  • 4
  • 55
  • 59