How to get file location in WiX Script

How to create a custom action that refers to a file on the command line?

I have a custom action that is correctly accessible to MYSQL properties, but I have not figured out a spell to access the path to the installed sql script.

Below are the relevant sections of the WiX script. I am trying to force a custom action to reference the path of the 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'/>
+3
source share
1 answer

Use [#MYSQL_SCRIPTS] conversion , this will translate the full file path during setup.

<CustomAction Id='LaunchFile' 
  FileKey='MYSQL_EXE'
  ExeCommand='--host=[MYSQL_SERVER]
  -u [MYSQL_USERNAME]
  -P [MYSQL_PORT]
  --password=[MYSQL_PASSWORD]
  -e [#MYSQL_SCRIPTS]' 
  Return='check'/>
+3
source

Source: https://habr.com/ru/post/1713582/


All Articles