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

LaunchApplication not picking up environment

I am in the process of migrating an InstallShield 2010 project to InstallShield 2011. The project includes a custom action implemented using InstallScript in order to set some special environment variables before launching an application. The InstallScript includes code similar to:

...
SetEnvironmentVariable("VARIABLE_NAME", INSTALLDIR);
LaunchApplication(, "", svAppPath, SW_HIDE, 0, LAAW_OPTION_NOWAIT);
...

With InstallShield 2010, the environment variable value set above is picked up by the application specified in LaunchApplication(). With InstallShield 2011, the environment is not picked up. The executable is still launched successfully, but functions incorrectly because the environment variable is not set.

Any ideas why this may have changed between releases?

Is there another approach that could be used to achieve the same outcome.

Thanks,
Neil.
Labels (1)
0 Kudos
(3) Replies
rrinblue22
Level 9

You can still get the LaunchApp working in the meanwhile.
try to use INSTALLDIR ^ something instead of the Environment variable
0 Kudos
readshaw
Level 2

It turns out this was related to a change between 2010 and 2011 to default to Unicode versions of Windows APIs. I changed 'SetEnvironmentVariable' to 'SetEnvironmentVariableA' and things worked as they did before the migration.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Since SetEnvironmentVariable is not prototyped in any InstallScript headers, the prototype being used needs to be updated to work correctly with Unicode (calling SetEnvironmentVariable with no explicit thunk (A/W) will result in the W version being called by the engine). For example, if the prototype was this before IS 2011:
prototype NUMBER KERNEL32.SetEnvironmentVariable(string, string);

Calling the Unicode (W) version of this API will not work with 'string' parameters. The prototype needs to be updated to work with Unicode parameters:
prototype NUMBER KERNEL32.SetEnvironmentVariable(wstring, wstring);

Using 'wstring' as the parameter types will tell the InstallScript engine to marshal string parameters by Unicode instead of ANSI.

Further information regarding Unicode changes in InstallScript are documented in the Upgrading Projects to InstallShield 2011 article.
0 Kudos