views:

107

answers:

1

How do I make a custom action that references a file on the command line?

I have the custom action accessing the MYSQL properties correctly, but I haven't figured out the incantation to access the path to the installed sql script.

Below are the relevant sections of the WiX script. I am trying to get the custom action to reference the path to MYSQL_SCRIPTS file.

<Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="ProgramFilesFolder">
   <Directory Id="INSTALLLOCATION" Name="MyProgram">
     <Directory Id="DbSetupDir" Name="DbSetup">
        <Component Id="SqlScripts" Guid="MYGUID">
           <File Id="MYSQL_EXE" Source="mysql.exe" Vital="yes" />
           <File Id="MYSQL_SCRIPTS" Source="MYSQL_SCRIPTS.sql" Vital="yes" />
        </Component>
     </Directory>
   </Directory>
 </Directory>

 ...

<CustomAction Id='LaunchFile' 
  FileKey='MYSQL_EXE'
  ExeCommand='--host=[MYSQL_SERVER]
  -u [MYSQL_USERNAME]
  -P [MYSQL_PORT]
  --password=[MYSQL_PASSWORD]
  -e [DbSetupDir]\ALS_Scripts.sql' 
  Return='check'/>
+1  A: 

Use the [#MYSQL_SCRIPTS] conversion, this will translate to the full path of those files at setup time.

<CustomAction Id='LaunchFile' 
  FileKey='MYSQL_EXE'
  ExeCommand='--host=[MYSQL_SERVER]
  -u [MYSQL_USERNAME]
  -P [MYSQL_PORT]
  --password=[MYSQL_PASSWORD]
  -e [#MYSQL_SCRIPTS]' 
  Return='check'/>
Shay Erlichmen
Thanks. The solution worked and the link was exactly what I was looking for.
Adam Tegen