+ Reply to Thread
Results 1 to 3 of 3

Thread: Environment Variable question

  1. #1

    Default Environment Variable question

    I am trying to set environment variables during an install in order to pass them to PowerShell scripts that communicate with a SQL server instance during setup. It doesn’t appear that SetupBuilder updates the environment variables at all. Here is what I found in the documentation:

    “On Windows NT-based systems, environment modification information is stored in the registry and a message notifies the system of changes when the installation completes. Any new processes, or existing processes that check for these messages, use the new or updated environment variables.”

    Does this mean that environment variables will not be updated until the SetupBuilder dialog completes? And if so, is there a way to force SetupBuilder to update the environment variables immediately so that I can pass them to my PowerShell script that checks for a specific environment variable.



  2. #2
    Join Date
    Mar 2004

    Default Re: Environment Variable question

    Hi Kurt,

    In Windows, modifications to the environment variables do not result in immediate change. For example, by default, if you start a Command Prompt after making the changes, the environment variables will reflect the previous (not the current!) values. The changes do not take effect until you log off and then log back on.

    To effect these changes without having to log off, SetupBuilder broadcasts a WM_SETTINGCHANGE message to all windows in the system, so that any interested applications can perform an update. But if an application does not handle this message, the environment variables will still reflect the previous (not the current) values.

    That is by Windows design and expected. I have created an example (please see the attached screenshots): the Command Prompt on Windows 10 (BEFORE.PNG) shows the environment variable "Path". We run a SetupBuilder installer to append "C:\yada" to the PATH variable. We display a simple Message Box so the installer does not continue. When we do again a SET in the same Command Prompt session, then PATH still has its "old" value. But when we start a new command prompt and do a SET, then you'll see the new value (AFTER.PNG).

    Does this help?

    Attached Images Attached Images    

  3. #3

    Default Re: Environment Variable question

    Yes, Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts