Environment Variables - Set

Declaration

<AMENVVARS ACTIVITY="set" NAME="text" TYPE="text (options)" 
VALUE="text" OVERWRITE="YES/NO"  />

Description: Sets the value of a system-level or user-level environment variable. If the variable does not exist, it will be created.

IMPORTANT: Any user can add, modify, or remove a user environment variable. However, only an administrator can add, modify, or remove a system environment variable.

Practical Usage

Commonly used to change the value of an existing environment variable or create a new environment variable with a specified value.

Environment Variable Parameters

Property

Type

Required

Default

Markup

Description

Environment Variable Scope

Text

Yes

User

  1. TYPE="user"

  2. TYPE="machine"

  3. TYPE="process"

The scope or level of the environment variable to set or create. The available options are:

  • User - A user-level (or local) environment variable will be created or set.

  • Machine - A machine-level environment variable will be created or set.

  • Process - A process-level environment variable will be created or set.

Environment Variable Name

Text

Yes

(Empty)

NAME="TEMP"

The name of the environment variable to set or create. If an environment variable with this name does not exist, it will be created.

New value

Text

Yes

(Empty)

VALUE="C:\Users\Temp"

The value to set for the new or existing environment variable.

Overwrite environment variable value

Yes/No

No

Yes

OVERWRITE="NO"

If set to YES (default), the value of an existing environment variable will be overwritten with the new value specified. If set to NO, the matching environment variable's existing value will stay intact, however, a runtime error will occur as a result.

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description This sample task demonstrates a number of activities related to environment variables. An Environment Variables - Set activity creates a new environment variable of type "User" named "AMTemp" along with the value of "Training". A Create Variable action creates a variable named "EnvironmentVarValue". An Environment Variables - Get activity populates the variable with the value of the newly created environment variable. Thereafter, a Message Box activity displays the value of the created environment variable. The final step deletes the environment variable with the use of the Environment Variables - Delete activity.

<AMENVVARS ACTIVITY="set" TYPE="USER" NAME="AMTemp" 
VALUE="Training" />
<AMVARIABLE NAME="EnvironmentVarValue"></AMVARIABLE>
<AMENVVARS TYPE="USER" NAME="AMTemp" 
RESULTVARIABLE="EnvironmentVarValue" />
<AMSHOWDIALOG>The value of environment variable 'AMTemp' is 
'%EnvironmentVarValue%'.</AMSHOWDIALOG>
<AMENVVARS ACTIVITY="delete" TYPE="USER" NAME="AMTemp" />