Set Environment Variables, Delete Environment Variables
Use the Tasks Set and Delete Environment Variables to add, change or delete environment variables on Agents.
For the option Append the value data if value already exists, add a semi-colon (;) in front of the value data that you want to append to the existing value. Without the semi-colon, the value will be replaced.
- It can be useful to combine this Task with the Task Query Environment Variables, to gather information about environment variables on Agents and to take action based on the query results.
- When using environment variables, they sometimes should not be translated to their value on a specific Agent, but should remain as variables. If you place double percentage signs (%) around a variable, the variable is not translated to a value, but remains a variable. For example, with double percentage signs, %%WINDIR%% is translated to %WINDIR% and not to C:\windows.
You want to set the user profile path for all Active Directory users as a variable %profilepath%, so that this path can be defined depending on the Operating System: C:\Documents and Settings\%username% on Windows XP machines, and C:\users\%username% on Windows 7 machines.
To achieve this, first use the Task Set Environment Variables to create the system environment variable %profilepath% with the correct values on Windows XP and Windows 7 machines. Then configure the Task Manage Active Directory User to set %%profilepath%% as the User property user profile path for all users.
As a result, all user profile paths in Active Directory are: %profilepath%. Due to this variable, the user profile path is resolved depending on the Operating System under which a user logs on: C:\Documents and Settings\%username% or C:\users\%username%.
- If the environment variables have been added or changed successfully, the system changes will be immediately available for new processes on Agent(s) that run the Task. Existing processes will continue to use the "old" environment variables.
- Job environment variables only exist during execution of the Job. After the Job has finished, all Job environment variables will be discarded.
- System environment variables are persistent, even when the Job has finished. Job environment variables are useful to parameterize batch files.