What is the difference between SET and SETX?

Asked

Viewed 849 times

6

To fix a new environment variable in Windows I checked that there are commands SET and SETX.

What is the exact difference between the two commands?

2 answers

7


SET

Set values immediately in the shell that you are working now. It dies when it is finished. It is embedded in itself shell, it is only a command recognizable by the cmd.

SETX

Assign values to all new sessions shells created and does not lose more until changed by another SETX. Sessions that are already running are not affected. It is a utility executable part by part, so it only works if it is accessible. With -m can be applied to all users. It is the only way to modify the environment variables programmatically.

  • 2

    Too fast :)

  • Then I can set the global JAVA_HOME with SETX instead of going in the environment variable window?

  • @Murillogoulart exactly.

  • Sensational. I suggest mentioning something about it in your answer. Which is a "global" set. Another thing, is it for all users or just the current one? Can complement also!

  • @Murillogoulart everyone needs to use -m.

6

Set

Modifies the environment variables of shell (window) that is running. The new value is available immediately, but it is temporary. The modification will not affect the rest of the operating system.

Setx

Modifies environment variables permanently. This affects all shells which will be opened in the future and is not valid for those who are currently running. You will need to close and open it again to make the changes available.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.