Search code examples
cmdcommand-lineglobal-variables

How to use global variable in arguments to setx command in cmd (command line)


Performed

setx /m DESKTOP %UserProfile%\Desktop

Real result

set DESKTOP
DESKTOP=C:\Users\dkurlyanov\Desktop

Desired result

set DESKTOP
DESKTOP=%UserProfile%\Desktop

I'm only interested in the option through the console


Solution

  • Correct answer from "Compo"

    setx /m DESKTOP ^%UserProfile^%\Desktop