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

Issues with LaunchApp while Upgrading from 2008 to 2011

We have an installer that runs several command files during the install. In IS 2008 we used LaunchApp and it worked. Now in IS 2011 it no longer works. The reason is that he command is executing with the working directory of C:\Windows\System32 and not the directory of where the command file is located at.

The code is as follows:

Cmd = INSTALLDIR^"Product Directory\\Commandfile.cmd";
LongPathToQuote(Cmd, TRUE);
Result = LaunchAppAndWait (Cmd, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN);

I have tried Adding the Option LAAW_OPTION_CHANGEDIRECTORY

I switched to using LaunchApplication and passed in the directory and I tried using ChangeDirectory before he call all to no avail.

Does anyone have any guidance on how I can execute the command file with its working directory set to where it is located?

Thanks

Kevin McKenzie
Labels (1)
0 Kudos
(4) Replies
MSIYER
Level 8

Try using LaunchAppAndWait i the following manner:
LaunchAppAndWait ( szProgram, szCmdLine, nOptions );
where
szProgram = ""
szCmdLine = path to the Commandfile.cmd file
nOptions = your options.
------------------------------------------------------
also try this
szProgram = path to cmd.exe
szCmdLine = path to the Commandfile.cmd file
nOptions = your options.
------------------------------------------------------
also try this
szProgram = "cmd.exe"
szCmdLine = path to the Commandfile.cmd file
nOptions = your options.

Also look at ChangeDirectory(). This is an Installscript function. You can use this in place of LAAW_OPTION_CHANGEDIRECTORY if the above options do not work.

Hope this helps...
0 Kudos
bkmckenzie
Level 3

I had already tried the ChangeDirectory call to no avail.

I tried to set Cmd to the cmd.exe and the Args to the command file.

Cmd = INSTALLDIR^"Product Directory\\Command File.cmd";
LongPathToQuote(Cmd, TRUE);
CmdExe = WINDIR^"System32\\CMD.EXE";
nResult = LaunchAppAndWait (CmdExe, Cmd, LAAW_OPTION_WAIT);
NumToStr(tmp, nResult);
return nResult;

It brings up the command window but does not run the file, just sits there at the command prompt.

What I have done to get around this is put the command file in the CMD and pass in the directory as a parameter in the arg and then modified the command files to change directory to the passed param. It works but I would rather do it the right way and not like that.

If anyone has any ideas please let me know

Thanks

Kevin McKenzie
0 Kudos
MSIYER
Level 8

Did you try all the three options?
Even the one where you pass ""(empty string) as the first parameter?
Also, check the existence of the said file before calling LaunchAppandWait.
0 Kudos
bkmckenzie
Level 3

Yes I ran all three

LaunchAppAndWait(CommandFile,"",LAAW_OPTION_WAIT) Runs in Windows/system32 Directory so the cammand script does not work as required

LaunchAppAndWait("", CommandFile,LAAW_OPTION_WAIT) Runs in Windows/system32 Directory so the cammand script does not work as required

LaunchAppAndWait("Cmd.exe", CommandFile,LAAW_OPTION_WAIT) Runs in Windows/system32 Dir But just opens a command window and sits at the prompt

LaunchAppAndWait("C:\Winsows\System32\Cmd.exe", CommandFile,LAAW_OPTION_WAIT) Runs in Windows/system32 Dir But just opens a command window and sits at the prompt

I also did this with the Change Directory Option and A File Exists Check and no change.

I am now reconfiguring my command files to accept the working directory as a parameter and to do a specific change directory command before running the rest of the script.

I have a tech support ticket open wih Flexaera on this and will post if I find anything else out. Other than that I will proceed with the parameter solution.

Thanks

Kevin McKenzie
0 Kudos