Setting Environment Variables in Windows for Specific User Login
In Windows, setting environment variables for a particular user login differs from setting system-wide variables. As you've mentioned, you have limited privileges to modify user-specific variables.
To set environment variables for your user only:
Using setx Command
Open the Command Prompt with administrator privileges and run the following syntax:
setx VariableName Value
Replace VariableName with the name of the variable you want to set (e.g., ADDR) and Value with the desired value (e.g., 127.0.0.1).
Example:
setx ADDR "127.0.0.1" setx TOKEN "ABCD1234"
The setx command modifies the permanent registry value, which affects future shells and programs without restarting your computer.
Using Registry Editor
You can also set user-specific environment variables through the Registry Editor. Navigate to the following registry key:
HKEY_CURRENT_USER\Environment
Right-click and select New > String Value.
Enter the variable name (e.g., ADDR) and set its value (e.g., 127.0.0.1).
Restart your computer or shell for the changes to take effect.
Verifying Environment Variables
Once you've set the environment variables using either method, you can verify their values by opening the Command Prompt and running:
echo %VariableName%
For example:
echo %ADDR%
The above is the detailed content of How to Set Environment Variables for a Specific User Login in Windows?. For more information, please follow other related articles on the PHP Chinese website!