Environment Variables - Set
Declaration
<AMENVVARS ACTIVITY="set" NAME="text" TYPE="text (options)" VALUE="text" OVERWRITE="YES/NO" />
Description
Sets the value of a system-level or user-level environment variable. If the variable does not exist, it will be created.
Practical usage
Commonly used to change the value of an existing environment variable or create a new environment variable with a specified value.
Parameters
Environment Variable
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Variable Scope | Text | Yes | User |
|
The
scope or level of the environment variable to set or create. The
available options are:
|
Environment variable | Text | Yes | (Empty) | NAME="TEMP" | The name of the environment variable to set or create. If an environment variable with this name does not exist, it will be created. |
New value | Text | Yes | (Empty) | VALUE="C:\Users\Temp" | The value to set for the new or existing environment variable. |
Overwrite environment variable value | Yes/No | No | Yes | OVERWRITE="NO" | If selected, the value of an existing environment variable will be overwritten with the new value specified. If disabled, the matching environment variable's existing value will stay intact, however, a runtime error will occur as a result. This parameter is selected by default. |
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 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 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" />