This documentation is archived and is not being maintained.

EnvironmentVariableTarget Enumeration

Specifies the location where an environment variable is stored or retrieved in a set or get operation.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

[<ComVisibleAttribute(true)>]
type EnvironmentVariableTarget

Member nameDescription
ProcessThe environment variable is stored or retrieved from the environment block associated with the current process.

The user creates the environment variable in a set operation.

When the process terminates, the operating system destroys the environment variable in that process.

UserThe environment variable is stored or retrieved from the HKEY_CURRENT_USER\Environment key in the Windows operating system registry.

When the user creates the environment variable in a set operation, the operating system stores the environment variable in the system registry, but not in the current process. If the user starts a new process, the operating system copies the environment variable from the registry to that process.

When the process terminates, the operating system destroys the environment variable in that process. However, the environment variable in the registry persists until the user removes it programmatically or by means of an operating system tool.

MachineThe environment variable is stored or retrieved from the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment key in the Windows operating system registry.

When a user creates the environment variable in a set operation, the operating system stores the environment variable in the system registry, but not in the current process. If any user on the local machine starts a new process, the operating system copies the environment variable from the registry to that process.

When the process terminates, the operating system destroys the environment variable in that process. However, the environment variable in the registry persists until a user removes it programmatically or by means of an operating system tool.

The EnvironmentVariableTarget enumeration is used by certain overloads of the SetEnvironmentVariable, GetEnvironmentVariable, and GetEnvironmentVariables methods to specify the location, or target, where the name and value of an environment variable is stored or retrieved.

The target can be one of three locations: the environment block associated with the current process, the Windows operating system registry key reserved for environment variables associated with the current user, or the registry key reserved for environment variables associated with all users on the local machine.

The following code example demonstrates the EnvironmentVariableTarget enumeration in methods that create, modify, and delete environment variables.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: