Environment Variables - List

Declaration

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

Related Topics   

Description

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

NOTE: 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.

Parameters

environment variable

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 - Variables available when the user for whom they were created is logged on to the computer (also known as local environment variables).  

  • Machine - Variables that are preset 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

Error Causes

On Error

Additional Notes

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

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