I have some file at Program\file.json
, and I want my .msi to copy the file to Program\Backup\file.json
before installing a new file at Program\file.json
so that the old data is not lost.
I tried writing a Program\backup.bat
which copies Program\file.json
to Program\Backup\file.json
and calling it with a CustomAction, but this does not work because I need to call the batch file after it is installed into the system's Program
folder during InstallFiles so that it can move the old file. However, InstallFiles is also when the new Program\file.json
overwrites the old one.
I also tried doing it the WiX way by putting the following tag in another Component within the same Feature as the File tag responsible for the new Program\file.json
:
<CopyFile SourceDirectory="ProgramFolder" DestinationDirectory="BackupFolder" Id="Copy_of_File" SourceName="file.json"/>
("ProgramFolder" is the Id of the Program Directory, and "BackupFolder" is the Id of the Program\Backup Directory)
However, this appears to copy the old version into Program\Backup\file.json
but not overwrite it with the new version. I'm not sure why.