0

I am creating two environment variable during installation. During installation itself those environment variables are being used by some of my batch files. But I cant find the environment variables available at the point when my batch files starts its execution. Post installation I can find the environment variable being set properly. What am I missing here? Is there any sequencing issue, like I am running my batch files before the environment variable is even set? Please shed some light on this I am trying this for past one week.

k.lo
  • 403
  • 2
  • 5
  • 13

1 Answers1

1

It would help to know exactly where your code is being run (sequenced) and whether it's deferred, impersonated and so on, and whether the variable is for the User or the System.

The issues tend to be:

  1. If it's deferred and running under the local system account it won't see a user variable.

  2. If it's impersonated it won't see any user variables because impersonation means only user account credentials - it does not mean load up the entire user profile (which is required to see the user variables).

  3. You might be doomed because Windows Installer doesn't broadcast or commit the changes until somewhere at the end of the install. A Commit custom action might find them, or a shell execute of a program after InstallFinalize might find them.

  4. Services don't see them because the SCM holds them from system boot time and doesn't refresh them.

  5. If you need a running program to pick them up after the install it needs to respond to the WM_SETTINGSCHANGED Windows message.

The first three are probably most relevant to your problem.

PhilDW
  • 20,260
  • 1
  • 18
  • 28