cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
insisha
Level 3

Batch file doesn't run the first time, but runs fine on a repair or if I put a message box just before calling LaunchAppAndWait

Jump to solution

I am using the following commands to run a batch file:

szOpenSSLPath = GetWebserverInstallDir() ^ "Programs";

szBatchFile = TARGETDIR ^ "\\Programs\\ABC_CertCreationScript.bat";
LongPathToQuote ( szBatchFile, TRUE );
LongPathToQuote ( szOpenSSLPath, TRUE );
ChangeDirectory ( TARGETDIR );
//Run the certificate script batch file
if (LaunchAppAndWait(szBatchFile, szOpenSSLPath, WAIT | LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN) < 0) then
 MessageBox ("Unable to install certificates, please do an install repair", 1);
endif;

 

When I install the setup for the first time, the batch file doesn't get executed.

However, it runs fine if I restart and do a repair.

Also, if I put a message box just before calling the LaunchAppAndWait method, the batch file runs on the first install.

I have a check to see if the batch file exists before calling LaunchAppAndWait.

Is the file copy not getting completed, or any locks on the file ?

The project type is msi version="2.0" xmlns:dt="urn:schemas-microsoft-com:datatypes" codepage="65001">

on Install Sheild 2012SpringSP1 SAB

Please help me out with the solution.

Thanks,

Siva

Labels (1)
0 Kudos
(1) Solution

Hi Banna_k

I got the solution 🙂

I am able to resolve this issue by moving the LaunchAppAndWait method call to the OnMoved event handler, instead of the OnMoveData.

I think the copying of the files happens asynchronously in the OnMoveData handler, therefore we were not getting the complete batch file to execute.

And, as OnMoved handler gets called at the end, we are sure that the file has been copied to the required location already.

Thanks for pointing out to the events, that helped me solve the case 🙂

View solution in original post

0 Kudos
(3) Replies
banna_k
Revenera
Revenera

Hi @insisha,

 As you have mentioned, see whether the file is present during the  LaunchAppAndWait execution.  

If it is a Basic MSI project, see when your Installscript function is getting called through custom action in the sequence, or if it is Install script MSI then check in which install script event the install script code is written. 

Ensure, the install script code is called after the file copy if you are calling the batch file from the installed location and sequence the code execution accordingly.

0 Kudos

In the event OnMoveData, the first step is to copy the batch file to a system folder,

followed by a the step LaunchAppAndWait(bat file path, args, WAIT)

Before executing the LaunchAppAndWait(), I also check for the presence of the file using

nResult = Is (FILE_EXISTS, TARGETDIR ^ "\\Programs\\ABC_CertCreationScript.BAT");
if (nResult = TRUE) then...

So the copy and run actions are sequential.

If I keep a message box just before running the batch file, the script gets executed.

Also, on a repair of the setup.

I might be missing a really trivial thing here.. but not able to track it down yet

0 Kudos

Hi Banna_k

I got the solution 🙂

I am able to resolve this issue by moving the LaunchAppAndWait method call to the OnMoved event handler, instead of the OnMoveData.

I think the copying of the files happens asynchronously in the OnMoveData handler, therefore we were not getting the complete batch file to execute.

And, as OnMoved handler gets called at the end, we are sure that the file has been copied to the required location already.

Thanks for pointing out to the events, that helped me solve the case 🙂

0 Kudos