Home  >  Article  >  Backend Development  >  How to Set Environment Variables for a Specific User Login in Windows?

How to Set Environment Variables for a Specific User Login in Windows?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-17 10:36:03652browse

How to Set Environment Variables for a Specific User Login in Windows?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn