Reputation: 1
I have created an installer using WIX toolset. Now I want to copy a file to the user's local system after installation. I have tried all possible ways with CopyFile
element but couldn't complete the problem.
I have tried using CopyFile
Element but couldn't copy the file.
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SAFTRUS_Application" />
<Directory Id="MyProgramDir" Name="SAFTRUS_Application">
<Directory Id="CopiedFiles" Name="Copied Files" />
</Directory>
</Directory>
</Directory>
<Fragment>
<DirectoryRef Id="MyProgramDir">
<Component Id="sAFtrUS" Guid="E8A58B7B-F031-4548-9BDD-
7A6796C8460D">
<File Id="FILE_InstallMeTXT" Source="ReadMe.rtf" KeyPath="yes">
<CopyFile Id="Copy_InstallMeTXT"
DestinationDirectory="CopiedFiles"
DestinationName="ReadMe1.rtf" />
</File>
</Component>
</DirectoryRef>
The file should be copied from installer to end user's system.
The File name is ReadMe.rtf
, this file is included in my setup project.
I want to copy this file to the user's local system where the application is, installed.
So if anyone has a solution, please help me.
Upvotes: 0
Views: 885
Reputation: 83
I used a CustomAction to do this. "copy" is not an executable, but rather a command available within cmd.exe, so you have to run "copy" from within the cmd.exe process
<CustomAction Id="copy.file" Directory="INSTALLFOLDER"
ExeCommand="[System64Folder]cmd.exe /c "copy ReadMe.rtf [WindowsFolder]System32\ReadMe.rtf""
Return="check" Execute="deferred" Impersonate="no" />
Then reference the action in a Custom element in the InstallExecuteSequence
<InstallExecuteSequence>
<Custom Action="copy.file" After="InstallFiles" />
</InstallExecuteSequence>
I ran into issues copying a file to C:\Windows\System32\drivers if the cmd.exe being used to run the "copy" command was not from the same folder. For instance if [SystemFolder]
was used (which is set to C:\Windows\SysWOW64 on 64-bit Windows) above instead of [System64Folder]
, it wouldn't work. Also didn't give an error either which was odd. From the install log, it looked like copy.file succeeded. Something to be aware of.
Upvotes: 0