What is the difference between SET and SETX?

5

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

What is the exact difference between the two commands?

    
asked by anonymous 20.02.2017 / 21:12

2 answers

6

SET

Assigns the values immediately in the shell session you are working on now. It dies when it is finished. It is built into the shell itself, it is just a command recognizable by cmd .

SETX

Assigns the values for all new shells sessions created and does not lose any more until changed by another SETX . Sessions that are already running are not affected. It is a separate executable utility, 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.

    
20.02.2017 / 21:20
3

Set

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

Setx

Modify environment variables permanently. This affects all shells that will be opened in the future and is not valid for the ones that are currently running. It will need to be closed and reopened for the changes to be available.

    
20.02.2017 / 21:23