Indigo Rose Software
  #1  
Old 04-28-2008
Adam's Avatar
Adam Adam is offline
Indigo Rose Staff Member
 
Join Date: May 2000
Location: Indigo Rose Software
Posts: 2,154
set environment variables

Question
How can I set environment variables

Answer
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:

Code:
-- 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 at 01:22 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Set the Default Application Directory Adam Setup Factory 8.0 FAQ 0 04-28-2008 11:58 AM
Creating environment variables gott Setup Factory 7.0 Discussion 18 09-11-2007 01:11 PM
Utility to create AMS Script to set Variables to "" Worm AutoPlay Media Studio 4.0 10 02-05-2003 01:54 PM
INFO: Setting Environment Variables Support Setup Factory 6.0 Knowledge Base 0 10-10-2002 01:07 PM
INFO: How to Set the Default Application Directory Support Setup Factory 6.0 Knowledge Base 0 09-25-2002 01:02 PM


All times are GMT -6. The time now is 10:21 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software