Setting Environment Variables on Windows

For me usual path for setting environment variables was

  • Right-click My Computer, select properties
  • Click Environment Variables button on Advanced tab
  • add a variable the usual way

One drawback of this approach is that your changes will only become available after machine restart. Not good enough for me! I searched the net and found this small tool called SETX that is part of Windows Resource Kit 2000

Setting an environment variable is now really simple. Just type and run this command in command prompt:
setx.exe VARNAME VALUE

That’s it you have set an environment variable and what’s important, no restart required.

P.S. to quickly test that it worked in new command prompt run this command set %VARNAME% and if you can see your variable in the output, it worked.

Update: this is another interesting forum entry on using setx to update PATH environment variable