setx

SETX not setting system variable when using /M


I am trying to set a persistent system variable. This is for a process in which a batch file refers to the variable, and then edits the variable at the end of the process.

I am using setx with the /M parameter, however, it continues to create the environment variable under the local user instead of the system.

The command I am specifically running is:

setx FN 101 /M

What am I missing?


Solution

  • I did not launch an elevated CMD. Turns out in order for the /M parameter to work, CMD must be run as an administrator.