At first glance this seems like a purely subjective/aesthetic issue, but I'd be interested to hear opinions (especially any technical ones) on whether environment variables or the registry is the preferred place for storing configuration data in a Windows environment.
I can currently only think of the following differences:
regedit
regedit
easier for non-command-line apps?)I'm also aware that environment variables can be interrogated, modified and set from the registry.
The difference between the two is that variables values may change during execution, while constant values cannot be reassigned. An environment variable is a variable whose value is set outside the program, typically through functionality built into the operating system or microservice.
Machine environment variables are stored or retrieved from the following registry location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment . Process environment variables are generated dynamically every time a user logs in to the device and are restricted to a single process.
Instead of environment variables, we recommend that you either use a YAML configuration file or a shared data source.
Use environment variables when you intend to be configured by other applications (or by a technical user) and that this configuration could be different (i.e. you have 2 instances running at the same time, with different settings). Cluttering a user's environment isn't usually necessary. In most cases, use the registry, or a config file stored in $HOME\AppData\Roaming\YourApp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With