How to set persistent user environment variables?

How can you set persistent user environment variables from VB6 code for an application that will run under privileges other than administrator?

I know SetEnvironmentValue , but apparently this only changes the vars for the current process, which is insufficient for my needs.

Since environment variables may be stored in the HKLM registry, I am concerned that a user who is not the administrator of my application will not be able to install env var.

+4
source share
3 answers

For the current user, environment variables are stored in /HKEY_CURRENT_USER/Environment , which should not require elevated privileges.

+2
source

VB6 Guru Karl Peterson has written a reusable module for handling user or system environment variables. See here from Visual Studio Magazine in 2009. Direct link to code

+2
source

I wrote this handy class a long time ago to do what you requested.

http://www.vbrad.com/pf.asp?p=Source/src_environment.htm

0
source

Source: https://habr.com/ru/post/1397936/


All Articles