Home > Backend Development > Golang > 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
Release: 2024-11-17 10:36:03
Original
711 people have browsed it

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
Copy after login

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"
Copy after login

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
Copy after login

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%
Copy after login

For example:

echo %ADDR%
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template