Run Program as PreInstallation Action

Comments

3 comments

  • Avatar
    wojciechka

    Regarding only having the file temporarily, you can use <writefile> to create it, then <runprogram> and finally <deletefile>. For example:

     <writeFile>
         <path>${system_temp_directory}/script.vbs</path>
         <text>
             (script contents)
         </text>
     </writeFile>
     <runProgram>
         <program>cscript</program>
         <programArguments>/NOLOGO "${system_temp_directory.dos}/script.vbs"</programArguments>
     </runProgram>
     <deleteFile>
         <path>${system_temp_directory}/script.vbs</path>
     </deleteFile>
    

    As for it not running, are you sure the script exits with non-zero exit code? If it exits with exit code 0, then nothing will be shown.

    You can add some debug commands (such as MsgBox("Hello world")) to verify that VBS is run.

    You can also specify invalid path to VBS script to check if the <runprogram> and error actions are run.

  • Avatar
    juanjo

    Is the <runProgram> failing? The <onErrorActionList> is just executed if the <runProgram> fails so if the program executes properly, the <throwError> will never appear, regardless of the rule. In addition, if you are using the <throwError> just to configure the message that the end user will get, you could simply set a <customErrorMessage> for the runProgram:

     <runProgram>
         <customErrorMessage>Please install the prerequisites first and then try this installer.</customErrorMessage>
         <program>cscript</program>
         <programArguments>/NOLOGO "${system_temp_directory.dos}/script.vbs"</programArguments>
     </runProgram>
    
  • Avatar
    Dracu

    Juanjo & wojciechka,

    Thanks for your help.

    Finally got what i wanted. Added a separate throwError after the runProgram and it did the job.

    <throwerror> <text>Prerequisites not installed. Please install them and run this installer.</text> <rulelist> <comparetext> <logic>does_not_equal</logic> <text>${program_exit_code}</text> <value>1</value> </comparetext> </rulelist> </throwerror>

Please sign in to leave a comment.