Environment Variables - List

Declaration

<AMLISTENVIRONMENTVARIABLES RESULTDATASET="Text" TYPE="Text" />

Description: Retrieves a list of existing user, machine or process level environment variables and populates a dataset with their names and values.

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 get a list of environment variables and then loop through the list using Loop dataset in order to perform operations on each one.

Environment Variable Parameters

Property

Type

Required

Default

Markup

Description

Variable scope

Text

Yes

User

  1. TYPE="user"

  2. TYPE="machine"

  3. TYPE="process"

The environment variable scope or level to retrieve the listing from. The available options are:

  • User - Variablesavailable when the user for whom they were created is logged on to the computer (also known as local environment variables).  

  • Machine - Variables that arepreset in the operating system and available to all Windows processes.

  • Process - Variables restricted to a single process.

Create and populate dataset

Text

Yes

(Empty)

RESULTDATASET="datasetName"

The name of the dataset  to create and populate with the names and values of the environment variables. More on the dataset names and field values that this activity creates can be found below under Datasets.

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.)

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields in addition to the standard dataset fields. The table below describes these fields (assuming the dataset name assigned was theDataset).

Name

Type

Return Value

theDataset.VarName

Text

Returns the name of the environment variable.

theDataset.VarValue

Text

Returns the value of the environment variable.

Example

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

Description: This sample task uses an Environment Variables - List activity (step 1) to retrieve all "user" level environment variables and populates a dataset with the results. A Loop dataset activity then loops through the dataset. Thereafter, a Message dialog activity displays each environment variable retrieved during each loop process.

<AMENVVARS ACTIVITY="list" TYPE="USER" 
RESULTDATASET="theDataset" />
<AMLOOP TYPE="DATASET" DATASET="theDataset"><AMSHOWDIALOG 
WINDOWTITLE="ENVIRONMENT VARIABLE NAME/VALUE">Environment 
Variable Name: %theDataset.VarName% Environment Variable Value:
%theDataset.VarValue%</AMSHOWDIALOG>
</AMLOOP>