A
A
Abdula Magomedov2015-11-01 23:51:20
Windows
Abdula Magomedov, 2015-11-01 23:51:20

Where are user environment variables stored?

Hey!
Such a thing. I wanted to write a small utility to add a directory to the PATH variable. I found where variables are stored in the registry, but only system ones.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
,
and only the administrator can get access to them, I decided to look for where user variables are stored,
I found it here:
HKEY_USERS\S-1-5-21-341354423-1384976903-1200731615-1000\Environment
,
but as I understand the line
S-1-5-21-341354423-1384976903-1200731615-1000
is generated automatically, and if it is written in the code, then it will not work on another computer.
So here's how I can change (programmatically) the user's PATH variable. Preferably in the AutoIT language, but it's not critical...
Or how can you unambiguously define a user directory in the registry so that it works on any computer. After all, other programs do it somehow, for example, node.js during installation, or the pathed program ,
Or maybe there is some utility like pathed , but without dependencies ...?
UPD:
ATP everyone. Utility is ready)
5731adeb32be4e0a96300c6c1225c38f.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey S., 2015-11-02
@Avarskiy

HKCU\Environment than does not suit? this is just the user who is currently logged in

V
Vladimir Martyanov, 2015-11-02
@vilgeforce

There is a SetEnvironmentVariable function that should change user variables. You don't need to know where they are stored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question