Environment Variables - Get

Declaration

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

Related Topics   

Description

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

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

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

Parameters

environment variable

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 AutoMate variable in which to populate with the value of the retrieved environment variable.

 

Description

Error Causes

On Error

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 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 "AutoMate Training". A Create variable action creates an AutoMate variable named "EnvironmentVarValue". An Environment variables - Get activity populates the AutoMate 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="AutoMate 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" />