I'd like to set a temporary enviroment variable in windows CMD line, which in my word the windows shell. because it's for temporary usage, So I don't want to add a new enviroment variable system wise by clicking "my computer-->properies---" ...

by the way, the envrioment variable I'd like to set is http proxy, but I don't known the windows syntax for that. so if you happen to know it as well, please tell me and I'll apreciate you even more ...


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.

  • 2
    It's not so much per session as per process and child process. Other processes already running in your login session will not see this new (or changed) variable, only the current cmd.exe process and any processes launched from it. – Richard Nov 18 '10 at 8:22
  • 1
    Sorry, with session I meant the current process; I just noticed that calling it session may be a bit confusing. – akseli Nov 19 '10 at 13:59
  • It's interesting to note that variable names may contain spaces (at least with this method), so if you add a space, that gets added to the variable name. Strange. – GregT Apr 27 '18 at 14:20

See the Microsoft Documentation for the details.


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

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

  • Question state "windows CMD line", not PowerShell – P-L Sep 13 '18 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.