win_environment – Modify environment variables on windows hosts¶
- Uses .net Environment to set or remove environment variables and can set at User, Machine or Process level.
- User level environment variables will be set, but not available until the user has logged off and on again.
- This module is best-suited for setting the entire value of an environment variable. For safe element-based management of path-like environment vars, use the win_path module.
- This module does not broadcast change events. This means that the minority of windows applications which can have their environment changed without restarting will not be notified and therefore will need restarting to pick up new environment settings. User level environment variables will require the user to log out and in again before they become available.
- win_path – Manage Windows path environment variables
- The official documentation on the win_path module.
- name: Set an environment variable for all users win_environment: state: present name: TestVariable value: Test value level: machine - name: Remove an environment variable for the current user win_environment: state: absent name: TestVariable level: user
Common return values are documented here, the following are the fields unique to this module: