Environment Variables - Get
Declaration
<AMENVVARS NAME="text" RESULTVARIABLE="text" TYPE="text (options)" />
Description
Retrieves the value of a machine, user or process level environment variable and places it into an Automate Desktop variable.
Practical usage
Used to populate an Automate Desktop 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 |
---|---|---|---|---|---|
Variable scope | Text | Yes | User |
|
The
scope or level of the environment variable to retrieve. The available options are:
|
Environment variable | Text | Yes | (Empty) | NAME="TEMP" | The name of the environment variable to retrieve. |
Populate variable with value | Text | No | (Empty) | RESULTVARIABLE="VarName" | The name of an already created Automate Desktop variable in which to populate with the value of the retrieved environment variable. |
Example
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
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 Variable - Create activity creates an Automate Desktop variable named "EnvironmentVarValue". An Environment Variables - Get activity populates the Automate Desktop variable with the value of the newly created environment variable. Thereafter, a Dialog - Message 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" />