Get Env Variable
Returns the value of the specified environment variable.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if the Catch node is used.
Input
- Variable Name - Name of the environment variable to get. (e.g.
DISPLAYorHOME)
Output
- Value - Value of the environment variable.
How It Works
The Get Env Variable node retrieves environment variable values from the operating system in a simple process:
- The node receives the variable name as input
- It validates that the variable name is not empty
- It queries the operating system for the environment variable value using the provided name
- The retrieved value (or empty string if not found) is stored in the output variable
- The message passes to the next node with the retrieved value
Requirements
- Variable Name: Must be a valid, non-empty environment variable name
- Operating System: Works on all platforms (Windows, Linux, macOS)
- Permissions: Standard user permissions (no special privileges required)
Error Handling
| Error Code | Description | Solution |
|---|---|---|
Core.Process.GetEnvVariable.ErrOnCreate | Configuration parsing failed during node creation | Check node configuration in the flow |
Core.Process.GetEnvVariable.OnMessage | Message parsing error | Verify message format is valid JSON |
Core.Process.GetEnvVariable | Variable name is empty | Provide a valid variable name |
Core.Process.GetEnvVariable.OutputMarshal | Failed to serialize output | Check output variable configuration |
Usage Examples
Example 1: Get User's Home Directory
// Get the HOME environment variable (Linux/macOS) or USERPROFILE (Windows)
msg.variableName = "HOME";
// After node execution:
// msg.homeDir contains "/home/username" or similar
Example 2: Get System Path
// Retrieve the PATH environment variable
msg.varName = "PATH";
// After node execution:
// msg.pathValue contains the system PATH variable
// Can be used to verify executable locations
Example 3: Get Custom Application Variable
// Get a custom environment variable set by another application
msg.envVar = "JAVA_HOME";
// After node execution:
// msg.javaHome contains the Java installation path
// Returns empty string if not set
Usage Notes
- If the environment variable does not exist, the node returns an empty string (not an error)
- Environment variable names are case-sensitive on Linux/macOS
- On Windows, environment variable names are case-insensitive
- The node retrieves variables from the current process environment
- Changes to environment variables made during flow execution will be reflected
- System-wide environment variables and user-specific variables are both accessible
Tips
- Always check if the returned value is empty before using it in subsequent operations
- Use this node to make flows portable across different environments
- Common variables:
HOME,PATH,TEMP,USER,DISPLAY(Linux),USERPROFILE(Windows) - Store configuration in environment variables rather than hardcoding values in flows
- Combine with conditional nodes to handle cases where variables might not be set
Related Nodes
- Start Process - Use environment variables to locate executable paths
- File Operations - Combine with file nodes to work with paths from environment variables
- String Operations - Process retrieved values (split PATH, extract portions, etc.)