cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
stiggy8
Level 4

Batch File Not Executing in IS2008

I realize that there are some updates in IS2008 regarding CAs and InstallScript. Although... I'm not sure why this isn't working.

Here is my function.
<><><>
function MyFunction(hMSI)

STRING svBatFile, svStatus;
STRING svBatDir, szMsg;
NUMBER nBuffer;

begin
MsiGetProperty(hMSI, "BKS_SW_DIR", svBatDir, nBuffer);
svBatFile = svBatDir ^ "MyBatch.bat";
SetStatusText("Batch File Path = " + svBatFile);
Delay(2);
if (LaunchAppAndWait(svBatFile, "", WAIT) < 0) then
MessageBox("Unable to execute batch script...", SEVERE);
endif;
end;
<><><>

The status text shows that the path being generated is correct... but the LAAW action fails. 😞

This worked fine in version 10.5 and in DevStudio 9... What am I doing wrong that it doesn't work in IS2008? :mad:

I'm using a Basic MSI project type as this function will be a part of a much bigger install.

Thanks.
Labels (1)
0 Kudos
(9) Replies
m_rudolph
Level 6

I had the same problem.

What's strange is the same script was working at one point, and then just stopped.

I have a 3rd party installation I launch that was defaulting to H:\ when it should be C:\ on some computers. I suspect it's due to our network here having every computer setup with a share on H:\. I've seen this behavior before with a Sentinel driver install.

Anyhow, in attempting to address that issue, I used ChangeDirectory:

ChangeDirectory( TARGETDISK + "\\" );
szPath = TARGETDISK + "\\";
LAAW_PARAMETERS.lpCurrentDirectory = &szPath;

In hopes of it grabbing the root drive that has win.ini (C:\ in most cases).

I haven't been able to test that fix since the machine I use is in another state and my build is copying (2 hours!), but I decided to use just ChangeDirectory (LocationOfBatchFile) before each LAAW call on each batch file using a test box here at my location.

They executed properly.
0 Kudos
stiggy8
Level 4

Added that block in without success.

As I mentioned... the path for the batchfile looks shows that it is initialized correctly. The test project I have is very simple... just creates the folder location in itne program files folder, dumps the batch file into the folder and then the CA is called with a Exec - AfterInstallFiles sequence.

I use Immediate Execution. If I use Deferred Execution, the path is not correctly initialized as would be expected and so the script call fails as well.

:mad: :mad: :mad:
So I'm still at square one??? Maybe I should fall back to IS10.5... This seems like a pretty simple tasks and for IS2008 to not be able to handle it make me want to seriously consider moving over to the Symantic install tool!
0 Kudos
RobertDickau
Flexera Alumni

There have been some changes to the InstallScript architecture starting with InstallShield 12; please see the sticky posts at the top of this forum.

If you want to launch a file that you're installing, it will need to be in deferred mode, since files and other data aren't written until deferred mode. And to get a property value using MsiGetProperty during deferred mode, you'll need to go through CustomActionData, about which see the links in the what's-new posts or search these forums.

(As an aside, you might see if it's an option to launch the batch file directly using a launch-an-EXE custom action; please search the forums and KB for "batch file custom action" for some approaches.)
0 Kudos
klacounte
Level 6

Try launching cmd.exe instead of the batch file. e.g. cmd.exe /c MyBatch.bat. If you support Win9x then cmd.exe won't be present and you'll have to use command.com instead. I think the COMSPEC environment variable will contain the correct command processor - cmd.exe on WinNT or command.com on Win9x.
0 Kudos
stiggy8
Level 4

Thanks for the suggestions...

The project is set to work for XP or 2003 boxes only. I've tried the full qualification approach as well without success.

I can also execute the batch file from the run box by giving it the full path and not using the executable name so I would assume that all of the environment variables are set as required.

So... there is something else I'm missing.

Will logging or debugging give me more information?

I'll try some other options... but it still appears that reverting to an older versions of IS is the best option.
0 Kudos
klacounte
Level 6

Logging/debugging won't help. The issue is that there are only 3 properties that can be accessed by a CA running in deferred mode: CustomActionData, ProductCode, and UserSID. The CustomActionData is a way to pass data from a CA running in immediate mode to a CA running in deferred mode. Based on your example that might not be necessary though. If I have time tomorrow I'll setup an example project for you.
0 Kudos
klacounte
Level 6

Okay, here's an example. There are two custom actions that call a batch file. The first one uses the run an executable custom action type which will work if you don't need to do any complex processing before running the batch file. The second one uses InstallScript to launch the batch file.

Hope this helps.
0 Kudos
stiggy8
Level 4

Thanks K

I'll try it first thing tomorrow on my work system... I appreciate your effort in trying to help.

S
0 Kudos
stiggy8
Level 4

It took me longer to try out your suggestions than I had hoped. Other tasks on the project were a higher priority. But finally tried out the fixes. Your examples did work on my system. Thanks again for the help.
0 Kudos