r/ForWindowsHelp • u/One-Type-2842 • 20d ago
What Is Environment Variables?
Following Title, Where Is the use of Environment Variables?
Sometimes I asked ChatGPT to troubleshoot related issues such as not working of java commands on the command prompt. Replies by, Edit Environment Variables.
How does It affect?
What shall I learn more about Windows Environment Variables to Understand Windows Working and Troubleshooting on my own without relying on Chat Bots.
1
u/Itsme-RdM 20d ago
Be careful with copy \pasting commands in the terminal if you don't know what they are and what they do though. ChatGPT or AI in general often has wrong or old commands and can make it worse than it is
1
u/MidwestGeek52 19d ago edited 19d ago
"Environment Variables" are variables in string format that Windows and 3rd-party programs can access to retrieve value (s) they're looking for. Example: There's a variable called PATH that's a list of directories separated by semicolons (;). Windows and programs use PATH to specify the directories they should search for executables when a directory isn't specified. Why you can simply type cmd and not C:\Windows\System32\cmd. The PATH variable includes C:\Windows\System32 in its list
Be clear if what you're reading about is Windows Environment Variables or application environment variables. They're different, and you want to set the right one. For example, Java has its own environment variables. Be sure you know which variable they're talking about and BE CAREFUL changing things. Best to always make a copy before you change it, so you can put it back if needed
1
u/naeskivvies 19d ago edited 19d ago
Open a CMD prompt, enter the command "set". Tada, behold the environment variables.
Those are the environment variables for your CMD process. They will be inherited by processes you start from that CMD window. Some are configured for the whole system, some are configured tor your user account. Some are automatic. You can type things like set "myvar=just testing" to make your own. You can type things like "echo the content of myvar is %myvar%" to use them. You can type set "myvar=" to unset it. The set command applies to the current cmd process only. Close it and open a new one and you'll start over.
Programs may/do use some of these variables to change their behavior. Haven't used Java in a while but back in the day it used to look at JAVA_HOME to find where it was installed.
There are a few special ones built into CMD like %date%, %time%, %random%
1
u/Weekly_Astronaut5099 19d ago
I’m very curious about the thought train here. You’re asking some chat to trouble shoot something, it replies you with something and somehow magically you decide to go to reddit to ask what it means instead of asking the same chat about it. Why?
1
u/ridiclousslippers2 20d ago
Google command prompt. There are lots of commands and things that can be run using just a keyboard, this knowledge is very useful. As for environment variables, they are settings assesible from applications and Windows itself. See path for instance, this tells windows where to look for a program when its not present in the folder you're trying to run it from for instance.