Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Visual Studio learn of new environment variables without having to restart my system

I've seen posts asking about how to get environment variables to be refreshed without having to close VStudio, but for me, I just want to know how I can make the changes without having to restart my system. I really don't understand how it can't detect the new changes - I've totally made sure the process is not hanging around and even used the vcvars32.bat to pick up new changes before re-opening. I can't find a solution. My environment variables can be used from elsewhere (ie. %variablename% works in cmd.exe). Any ideas?

like image 845
mina Avatar asked Jul 16 '11 02:07

mina


People also ask

Do I need to restart after changing environment variables?

No, you don't need to restart your system. However, you have to restart your command prompt application to update the changes done on Environment variables.

How do I change environment variables in Visual Studio?

In Visual Studio 2019 right-click your project, choose Properties . In the project properties window, select the Debug tab. Then, under Environment variables change the value of your environment from Development to Production or other environments.

How do I permanently set environment variables?

You can set an environment variable permanently by placing an export command in your Bash shell's startup script " ~/. bashrc " (or "~/. bash_profile ", or " ~/. profile ") of your home directory; or " /etc/profile " for system-wide operations.

How do I permanently set environment variables in Windows?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.


2 Answers

The environment that is being used is the one from windows explorer. You would have to restart explorer for the changes to appear.

There is a way to apply the changes to the current environment. You might want to try SuperUser.com

like image 64
Brad Bruce Avatar answered Sep 30 '22 10:09

Brad Bruce


Since the new environment variable is visible in the cmd window, why not start VS from there? The devenv command will start the VS IDE. You can tell it to load a particular solution or project.

devenv  [solutionfile | projectfile | anyfile.ext]  [switches]

The VS IDE will pick up the environment variable state that's in effect in that cmd window. However, note that certain environment variables will not be picked up unless you use the /useenv option:

  • /useenv: Use PATH, INCLUDE, LIBPATH, and LIB environment variables instead of IDE paths for VC++ builds.

Also note that it also accepts a bunch of options (mainly to build projects from the command line); use devenv /? to get details.

like image 20
Michael Burr Avatar answered Sep 30 '22 10:09

Michael Burr