cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Chris_McElyea
Level 2

Problem using LaunchAppAndWait

Dear Community,

I have an InstallScript that needs to pass 2 parameters to the LaunchAppandWait function. The problem is that the parameters use the INSTALLDIR as part of the parameter. If the INSTALLDIR has spaces in it, the external program views that as another parameter and causes it to fail. How do I pass the first and second parameters to the external program so that the spaces are not viewed as parameter separators. He is the code:

STRING szParm1, szParm2, szParm3;

szParm1 = INSTALLDIR^"MyApp.exe ";
szParm2 = INSTALLDIR^"MyApp.ini";
szParm3 = szParm1 + szParm2;

LaunchAppAndWait(INSTALLDIR ^ "ChangeIt.exe", szParm3, LAAW_OPTION_WAIT);
Labels (1)
0 Kudos
(2) Replies
phill_mn
Level 7

There are several different approaches you can take. For param1 you can call the LongNameToShort function but for the other parameters (and therefore also for param1) you can wrap the paths with quotes. Generally use double quotes, and if a parameter already has double quotes, convert them to single quotes.

STRING szParm1, szParm2, szParm3;

szParm1 = "\"" + INSTALLDIR^"MyApp.exe \"";
szParm2 = "\"" + INSTALLDIR^"MyApp.ini \"";
szParm3 = szParm1 + szParm2;

LaunchAppAndWait(INSTALLDIR ^ "ChangeIt.exe", szParm3, LAAW_OPTION_WAIT);

or use LongPathToQuote
0 Kudos
phill_mn
Level 7

In thinking about his I am not clear on whether your app takes a single command line parameter or whether you are intending to pass two parameters, which is what I assumed in the other post.

if param3 needs to be a single string then do:
szParm1 = "'" + INSTALLDIR^"MyApp.exe '"; //use single quotes
szParm2 = "'" + INSTALLDIR^"MyApp.ini '"; //use single quotes
szParm3 = "\"" + szParm1 + szParm2 + "\""; //wrap the space separated single quoted args with double quotes so that changeit.exe thinks there is only one arg
0 Kudos