- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Batch file doesn't run the first time, but runs fine on a repair or if I put a message box just befo...
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
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 🙂