I am trying to create and access an environment variable in Windows 10.
I can create environment variables in System Properties >> Environment Variables, but whenever I try to access them using Environment.GetEnvironmentVariable(), the function fails to find the variable I created.
Instead, I have started using Environment.SetEnvironmentVariable() to create the desired variable, then I am able to access it using GetEnvironmentVariable(). Unfortunately this variable is not added to the System Environment variables, so I always have to create it at runtime.
Is there a better method for getting system environment variables? I don't want to hardcode the environment variable for security reasons, and I don't want to prompt the user to enter the information at runtime. I would prefer a solution that allows each user to manually create their own.