Environment Variables - List

Declaration

<AMENVVARS ACTIVITY="list" RESULTDATASET="text" TYPE="text (options)" />

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 the Loop - Dataset activity in order to perform operations on each one.

Parameters

Environment Variable

Property Type Required Default Markup Description
Variable scope Text Yes User
  • TYPE="user"
  • TYPE="machine"
  • TYPE="process"
The environment variable scope or level to retrieve the listing from. The available options are:
  • User (default) - 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.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

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 Dialog - Message activity displays each environment variable retrieved during each loop process.

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