No announcement yet.

set environment variables

  • Filter
  • Time
  • Show
Clear All
new posts

  • set environment variables

    How can I set environment variables

    This article explains how to set environment variables using Setup Factory 7.0

    Setting environment variables is done differently on Windows 9x operating systems (Windows 95, 95, ME) than it is on Windows NT operating systems (Windows NT 4.0, 2000, XP). This article will explain how to set environment variables on both types of operating systems.

    Windows 9x

    On Windows 9x operating systems, environment variables are set in the Autoexec.bat file, this file will be located on the root of the C:\\ drive: "C:\\Autoexec.bat"

    In order to set an environment variable the following line must be inserted into the "Autoexec.bat" file:

    Where "EnvVariable" is the name of the environment variable that you are setting, and "Value" is the value that will be assigned to the environment variable.

    Use the following script to insert a line into your autoexec.bat file:

    -- Set various constants
    Autoexec_Location = "C:\\\\Autoexec.bat";
    Environment_Variable = "Env_Variable=Value";
    -- Read from the file
    Contents = TextFile.ReadToTable(Autoexec_Location);
    -- Add a line to the table
    Table.Insert(Contents, Table.Count(Contents) + 1, Environment_Variable);
    -- Write to file
    TextFile.WriteFromTable(Autoexec_Location, Contents, false);</pre></code>
    Windows NT

    When a user logs on to Windows NT, the system obtains the initial set of environment strings by examining two keys in the registry.

    The two keys are:

    - HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Con trol\\Session Manager\\Environment
    - HKEY_CURRENT_USER\\Environment

    System Variables (environment variables available to all users of the
    system) are set in: "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Co ntrol\\Session Manager\\Environment".

    User variables (environment variables available to only the current user)
    are set in: "HKEY_CURRENT_USER\\Environment".

    In order to set an environment variable in Windows NT you need to create a registry value in one of those two registry keys. The name of the Registry value will be the name of the environment variable, and the value of the Registry value will be the value that will be assigned to the environment variable.

    You can modify the registry to include new environment variables by using the Registry.SetValue() action.

    NOTE: When setting variables like this on Windows 9x or Windows NT, the system MUST be restarted for them to take effect.

    For more information please visit the following sources:

    Knowledge Base Article - Q100843 Environment Variables in Windows NT

    -Program Reference | Actions | Registry | Registry.SetValue
    -Program Reference | Actions | TextFile | TextFile.ReadToTable
    -Program Reference | Actions | TextFile | TextFile.WriteFromTable
    Last edited by Adam; 04-29-2008, 12:22 PM.