Search code examples
windowscmdsession-variables

Session Environment Variables for Windows CMD shell


I understand from my googling that on *nix systems you can use the export command to set a temporary environment variable for the current session. What's the Windows equivalent for the plain old CMD shell?


Solution

  • I finally figured out that SET is the equivalent of export.

    Furthermore, to reference the variable, it needs to be surrounded by percent signs:

    SET MY_VARIABLE=42
    echo %MY_VARIABLE%
    

    SET documentation: ss64.com/nt/set.html