Copy a file from the installation location to another location on wix during installation

I created an msi installation file that contains some files in the "Sample" folder that should be copied to a temporary folder. Someone tell me how to do this?

+6
windows-installer wix
source share
2 answers

Something like that:

  <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="MyVendor" Name="MyVendor"> <Directory Id="INSTALLDIR" Name="MyDir"> <Component Id="MyFileId" Guid="...G1..."> <File Id="MyFileId" Name="MyFile" Source="...blabla...\MyFile" KeyPath="yes" > </File> </Component> <DirectoryRef Id="TARGETDIR"> <Component Id="MyFileCopyId" Guid="...G2..."> <RemoveFile Id="MyFileRemoveId" Name="MyFile" On="install" Directory="MyCopyDir" /> <CopyFile Id="MyFileCopyId" FileId="MyFileId" DestinationDirectory="MyCopyDir" /> </Component> <Feature Id="MyFeature" ... > <ComponentRef Id="MyFileId" /> <ComponentRef Id="MyFileCopyId" /> 

An important element of Xml is CopyFile. You need to create a new component, which is a copy of the first (with different identifiers, tips, ... of course). Both components must be declared in a function.

+8
source share

CopyFile element is your friend. You can nest it under the original File element several times, depending on how many times you need to copy it. Place the correct destination folder and let the Windows installer do the rest.

+2
source share

All Articles