how to set ENV variable in windows CMD line

Solution 1:

To set a temporary or 'per session' environment varible from a command line you can use:

set ‹var name›=‹value>

Make sure your spacing is exactly as shown above, if you add a space between the equal sign the command will fail.

Check: http://xahlee.org/mswin/env_var.html for a nice tutorial and info on environment variables.

Solution 2:

SET VAR_NAME=value

See the Microsoft Documentation for the details.

Solution 3:

If you are using PowerShell, then you need to use the $env prefix for creating an environment variable.

Here's an example:

$env:<var name> = '<value>'