Create Folders from text file and place dummy file in them using a CustomAction
- by Birkoff
I want my msi installer to generate a set of folders in a particular location and put a dummy file in each directory.
Currently I have the following CustomActions:
<CustomAction Id="SMC_SetPathToCmd" Property="Cmd" Value="[SystemFolder]cmd.exe"/>
<CustomAction Id="SMC_GenerateMovieFolders" Property="Cmd" ExeCommand="for /f "tokens=* delims= " %a in ([MBSAMPLECOLLECTIONS]movies.txt) do (echo %a)" />
<CustomAction Id="SMC_CopyDummyMedia" Property="Cmd" ExeCommand="for /f "tokens=* delims= " %a in ([MBSAMPLECOLLECTIONS]movies.txt) do (copy [MBSAMPLECOLLECTIONS]dummy.avi "%a"\"%a".avi)" />
These are called in the InstallExecuteSequence:
<Custom Action="SMC_SetPathToCmd" After="InstallFinalize"/>
<Custom Action="SMC_GenerateMovieFolders" After="SMC_SetPathToCmd"/>
<Custom Action="SMC_CopyDummyMedia" After="SMC_GenerateMovieFolders"/>
The custom actions seem to start, but only a blank command prompt window is shown and the directories are not generated.
The files needed for the customaction are copied to the correct directory:
<Directory Id="WIX_DIR_COMMON_VIDEO">
<Directory Id="MBSAMPLECOLLECTIONS" Name="MB Sample Collections" />
</Directory>
<DirectoryRef Id="MBSAMPLECOLLECTIONS">
<Component Id="SampleCollections" Guid="C481566D-4CA8-4b10-B08D-EF29ACDC10B5" DiskId="1">
<File Id="movies.txt" Name="movies.txt" Source="SampleCollections\movies.txt" Checksum="no" />
<File Id="series.txt" Name="series.txt" Source="SampleCollections\series.txt" Checksum="no" />
<File Id="dummy.avi" Name="dummy.avi" Source="SampleCollections\dummy.avi" Checksum="no" />
</Component>
</DirectoryRef>
What's wrong with these Custom Actions or is there a simpler way to do this?