Get Environment Variable

This Automation Manager object returns the value of the given environment variable.

Privileges

Normal

Input Parameters

Name Type Required Description

Variable

String

Yes

The name of the environment variable to return.

Type

String

Yes

The type of variable as either User, or Machine (System), or Process.

For devices using Windows operating systems, the Type of environment variable falls into one of three categories:

  • User environment variables are configured for each individual user. A user's environment block represents the environment variables that Windows maintains for that particular user, including the set of Machine environment variables. The most common reason for adding User environment variables is to provide data that is required for variables to be used in scripts. Any user can add, modify, or remove a User environment variable. The changes are written to the registry and take effect immediately. After User environment variables are modified, however, any open software programs should be re-started to force them to refer to the new registry values. When a user creates a User environment variable in a set operation, Windows stores the environment variable in the system registry but not during the current process. If the user starts a new process, Windows copies the environment variable from the registry to that process. When the process terminates, Windows destroys the environment variable in that process. The environment variable in the registry will persist, however, until the user removes it using a program or by means of an operating system tool. User environment variable are stored or retrieved from the following registry location: HKEY_CURRENT_USER\Environment.
  • Machine (or System environment variables are configured for all users. When a user creates a Machine environment variable in a set operation, Windows stores the environment variable in the system registry but not during the current process. If any user on the local machine starts a new process, Windows copies the environment variable from the registry to that process. When the process terminates, Windows destroys the environment variable in that process. The environment variable in the registry will persist, however, until a user removes it by using a program or by means of an operating system tool. Only administrator-level accounts can modify a Machine environment variable. Changes to the system environment are written to the registry and usually require the computer to be re-started to take effect. Machine environment variables are stored or retrieved from the following registry location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment.
  • Process environment variables are generated dynamically every time a user logs in to the device and are restricted to a single process. Process environment variables are stored or retrieved from the environment block associated with the current process. The user creates the environment variable in a set operation and when the process terminates, Windows destroys the environment variable in that process.

Output Parameters

Name Type Description
Result Number Returns a success value of zero or any value other than zero to indicate failure.
Value String The value of the environment variable.

Example Input Parameters

Name Type Required Example

Variable

String

Yes

ALLUSERSPROFILE

APPDATA

CAARCFLASH_HOME

CommonProgramFiles

CommonProgramFiles(x86)

CommonProgramW6432

COMPUTERNAME

ComSpec

FP_NO_HOST_CHECK

LOCALAPPDATA

NUMBER_OF_PROCESSORS

OS

Path

PATHEXT

PROCESSOR_ARCHITECTURE

PROCESSOR_ARCHITEW6432

PROCESSOR_IDENTIFIER

PROCESSOR_LEVEL

PROCESSOR_REVISION

ProgramData

ProgramFiles

ProgramFiles(x86)

ProgramW6432

PSModulePath

PUBLIC

SystemDrive

SystemRoot

TEMP

TMP

USERDOMAIN

USERNAME

USERPROFILE

Windir

Environment variables will differ depending on OS and installed applications

Type

String

Yes

Process