Environment Variables - Get

Declaration

<AMENVVARS NAME="text" RESULTVARIABLE="text" TYPE="test (options)" />

Description: Retrieves the value of a machine, user or process level environment variable and places it into a variable.

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

Used to populate a variable with the current value of a particular environment variable so the data can be called upon in subsequent task steps.

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 retrieve. The available options are:

  • User (default) - Remove a user-level environment variable.

  • Machine - Remove a machine-level environment variable.

  • Process - Remove a process-level environment variable.

Environment variable name

Text

Yes

(Empty)

NAME="TEMP"

The name of the environment variable to retrieve.

Populate variable with the value

Text

No

(Empty)

RESULTVARIABLE="VarName"

The name of an already created variable in which to populate with the value of the retrieved environment variable.

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" />