How To Get Environment Variable In Windows Command Prompt. On a traditional Windows machine, here's what you'd see: echo %USERNAME% will output foo. echo %USERPROFILE% will output C:\Users\foo. This will output the environment variables list to the output.txt file.
For example, the PATH environment variable is always set in Windows environments. Now we need to use the reg delete command to remove it. To set persistent environment variables at the command line, we will use setx.exe.
Read environment variables by command line.
All these information can be listed just issuing the set command without any parameter like below. $ set List All Environment Variables Get/Print Single Environment Variable.
Specifically, the path to the subkey is:. Removing an environment variable permanently is a bit more complex — you have to use reg to do it. Many environment variables will simply take a name and value, like.