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

GetEnvVar not working?

Hello all, having a problem passing data into an InstallScript-driven installer.

I run IsCmdBld using NAnt and TeamCity. The following NAnt snippet:

        







Does as it should, echoing the environment variable that was set to the value of the system.spam.spam variable (which TeamCity passes to NAnt as spam.spam).

However, when I run IsCmdBld:

        





...


on an ISM that has the following script code:

	STRING Flavor;
GetEnvVar("TESTTEST", Flavor);
MessageBox(Flavor, WARNING);


I get a blank message box. I had expected the text of the message box to contain the same value as was echoed in the first NAnt snippet. The same thing occurs if I use an environment variable in TeamCity directly (instead of setting one on the fly in the NAnt script), it seems to be ignored entirely. Am I missing something vital?

Thanks
Labels (1)
0 Kudos
(2) Replies
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The GetEnvVar function is a thin wrapper around the Win32 GetEnvironmentVariable API. As long as the requested variable is set for the InstallScript setup process, this API should return the value as expected.

You may try using the Process Explorer utility from www.sysinternals.com to see what environment variables are available to the running InstallScript setup process as a way to further troubleshoot this issue. Typically, a launched process inherits the launching process' environment block unless a new one is provided explicitly to CreateProcess (in other words, the process that was launched has no control over the environment block it receives).
0 Kudos
troycumbo
Level 3

Thanks Josh, this is apparently related to how CreateProcess works differently for executables vs. batch files; wrapping the call to IsCmdBld in a batch file allowed InstallShield to see the environment variable being set during the exec task.
0 Kudos