As an additional bit of information: While SET works with global or system variables, sometimes you want to write and read User variables, and this is done with the SETX command. SETX is included in the base installs of Windows beginning with Vista, but was also available in Windows XP by installing the Resource Pack.
One difference about SETX though is that you cannot read the variable out in the same command window you wrote it in. You have to write the SETX command in one Command or Powershell window, and then open a new window to read it using ECHO.
SETX can also write global or system variables.
To Set a user variable using SETX:
setx variable value
To set a global or system variable using SETX:
setx /m variable value
To read a user or global variable:
Remember, you must open a new Command or Powershell window to read this variable.
echo %variable%
Perhaps relevant: https://stackoverflow.com/questions/1884071/windows-echo-command-cant-echo-a-user-set-variable
– Technophile – 2017-10-30T21:51:24.8372
echo %path:;=&echo.%
gets the pretty list of semicolon separated paths. Works if a variable does not contain special characters like&
or^
. – Andry – 2018-07-05T17:22:14.8431the command to print path in Windows command shell is:
path
– Vyacheslav Lanovets – 2019-05-02T05:46:27.25326@Daniel: I know how to set environment variables in Windows, I simply open "System properties" > "Advanced" and "Environment Variables". So I don't expect the answer to my question in a question titled with "How do I set PATH and other environment variables?", because I know that! I'm not asking about how to set them. – Jonas – 2011-10-01T12:00:15.543
In a way you're right - as one of the authors in the other topic, I haven't actually noticed the exact wording for a long time. I edited that topic to reflect its actual contents. I'm not going to change the vote though, both because I can't, and because I stand by my assessment that this topic shows no research effort. – Daniel Beck – 2011-10-01T12:14:42.060