# Set Environment Variable

> Creates or updates a Windows environment variable for the whole endpoint. The variable is always a System variable; there is no per user option.

Source: https://docs.capaone.com/capaone/application-manager/powerbricks/bricks/set-environment-variable/  
Product: CapaOne — a separate CapaSystems product; do not apply this page to any other.

Creates or updates a Windows environment variable for the whole endpoint. The variable is always a System variable; there is no per user option. The brick can also add a folder to a path style variable such as PATH without creating duplicates.\\n\\nEvery program started after the brick has run reads the new value. Programs a signed-in user already has open keep the old one until they are restarted, and signing out and back in is the reliable way to refresh all of them.

## Parameters

#### Variable Name
*Required*

The name of the environment variable to create or update. The name cannot contain an equals sign.\\n\\nExample:\\nJAVA_HOME\\nPath

#### Variable Value
*Optional*

The value to give the variable. When the mode adds a folder to a path style variable, this must be a single folder path without semicolons and it is required.\\n\\nSpaces before and after the value are removed, so a value that was pasted with a stray space around it still works.\\n\\nExample:\\nC:\\Program Files\\MyApp\\n%ProgramFiles%\\MyApp

#### Mode
*Required* — Default: `Set`

How the value is applied.\\n\\nSet - Replaces the value of the variable with the value you specified.\\n\\nAppend To Path - Adds the folder to the end of a path style variable such as Path. Existing entries are kept in the same order. When the folder is already in the variable, it is left where it is and nothing changes.\\n\\nPrepend To Path - Adds the folder to the front of a path style variable so it is found first. When the folder is already in the variable further back, it is moved to the front so it appears only once, and every other entry keeps its order. When it is already the first entry, nothing changes.\\n\\nThe folder is matched without regard to upper or lower case and a trailing backslash is ignored, so C:\\Program Files\\MyApp\\ matches C:\\Program Files\\MyApp. Allowed values: `Set`, `Append To Path`, `Prepend To Path`.

#### Allow Variable References In The Value
*Optional* — Default: `False`

Enable when the value contains references to other environment variables that must be resolved when the value is read, for example %ProgramFiles%\\MyApp. Disable to store the value exactly as typed.\\n\\nWhen a folder is added to an existing path style variable that already resolves references, that behavior is always kept so existing entries do not break.

## Details

- **Category:** System
- **Brick ID:** `Environment-Variable-Set`

## Raw JSON definition

```json
{
  "category": "system",
  "description": "Creates or updates a Windows environment variable for the whole endpoint. The variable is always a System variable; there is no per user option. The brick can also add a folder to a path style variable such as PATH without creating duplicates.\\n\\nEvery program started after the brick has run reads the new value. Programs a signed-in user already has open keep the old one until they are restarted, and signing out and back in is the reliable way to refresh all of them.",
  "developerVendor": "CapaSystems A/S",
  "displayName": null,
  "id": "Environment-Variable-Set",
  "name": "Set Environment Variable",
  "parameters": [
    {
      "allowManualInput": false,
      "defaultValue": "",
      "defaultValueObject": null,
      "description": "The name of the environment variable to create or update. The name cannot contain an equals sign.\\n\\nExample:\\nJAVA_HOME\\nPath",
      "id": "VariableName",
      "name": "Variable Name",
      "regExValidation": "",
      "required": true,
      "type": "TextBox",
      "value": null,
      "values": [],
      "valuesObject": null
    },
    {
      "allowManualInput": false,
      "defaultValue": "",
      "defaultValueObject": null,
      "description": "The value to give the variable. When the mode adds a folder to a path style variable, this must be a single folder path without semicolons and it is required.\\n\\nSpaces before and after the value are removed, so a value that was pasted with a stray space around it still works.\\n\\nExample:\\nC:\\Program Files\\MyApp\\n%ProgramFiles%\\MyApp",
      "id": "VariableValue",
      "name": "Variable Value",
      "regExValidation": "",
      "required": false,
      "type": "TextBox",
      "value": null,
      "values": [],
      "valuesObject": null
    },
    {
      "allowManualInput": false,
      "defaultValue": null,
      "defaultValueObject": {
        "id": "Set",
        "name": "Set"
      },
      "description": "How the value is applied.\\n\\nSet - Replaces the value of the variable with the value you specified.\\n\\nAppend To Path - Adds the folder to the end of a path style variable such as Path. Existing entries are kept in the same order. When the folder is already in the variable, it is left where it is and nothing changes.\\n\\nPrepend To Path - Adds the folder to the front of a path style variable so it is found first. When the folder is already in the variable further back, it is moved to the front so it appears only once, and every other entry keeps its order. When it is already the first entry, nothing changes.\\n\\nThe folder is matched without regard to upper or lower case and a trailing backslash is ignored, so C:\\Program Files\\MyApp\\ matches C:\\Program Files\\MyApp.",
      "id": "Mode",
      "name": "Mode",
      "regExValidation": "",
      "required": true,
      "type": "ComboBox",
      "value": null,
      "values": [],
      "valuesObject": [
        {
          "id": "Set",
          "name": "Set"
        },
        {
          "id": "AppendToPath",
          "name": "Append To Path"
        },
        {
          "id": "PrependToPath",
          "name": "Prepend To Path"
        }
      ]
    },
    {
      "allowManualInput": false,
      "defaultValue": "False",
      "defaultValueObject": null,
      "description": "Enable when the value contains references to other environment variables that must be resolved when the value is read, for example %ProgramFiles%\\MyApp. Disable to store the value exactly as typed.\\n\\nWhen a folder is added to an existing path style variable that already resolves references, that behavior is always kept so existing entries do not break.",
      "id": "Expandable",
      "name": "Allow Variable References In The Value",
      "regExValidation": "",
      "required": false,
      "type": "Boolean",
      "value": null,
      "values": [],
      "valuesObject": null
    }
  ],
  "powershell": {
    "base64Encoded": true,
    "function": "ZnVuY3Rpb2..."
  },
  "type": "powerbrick",
  "version": "2026.10.8.1"
}
```
