EnvGet

Retrieves the value of the specified environment variable.

Value := EnvGet(EnvVar)

Parameters

EnvVar

Type: String

The name of the environment variable, e.g. "Path".

Return Value

Type: String

This function returns EnvVar's value. If EnvVar has an empty value or does not exist, an empty string is returned.

Remarks

The operating system limits each environment variable to 32 KB of text.

This function exists because normal script variables are not stored in the environment. This is because performance would be worse and also because the OS limits environment variables to 32 KB.

EnvSet, Run / RunWait

Examples

Retrieves the value of an environment variable and stores it in LogonServer.

LogonServer := EnvGet("LogonServer")

Retrieves and reports the path of the "Program Files" directory. See RegRead example #2 for an alternative method.

ProgramFilesDir := EnvGet(A_Is64bitOS ? "ProgramW6432" : "ProgramFiles")
MsgBox "Program files are in: " ProgramFilesDir

Retrieves and reports the path of the current user's Local AppData directory.

LocalAppData := EnvGet("LocalAppData")
MsgBox A_UserName "'s Local directory is located at: " LocalAppData