开发者

how to ensure that VSVARS32.BAT batch file have permanent effect?

开发者 https://www.devze.com 2023-01-07 08:57 出处:网络
If I need to use microsoft C# compiler from the normal command prompt, it says right here how and it says right here how I set the environmen开发者_如何学JAVAt variable (by running VSVARS32.BAT). I ex

If I need to use microsoft C# compiler from the normal command prompt, it says right here how and it says right here how I set the environmen开发者_如何学JAVAt variable (by running VSVARS32.BAT). I execute it and after that I can run "csc" (the compiler). However the effect seems to disappear when I close the command line window that run VSVARS32.BAT

Is there a way to make the environment variables permanent, so that I can run csc.exe from an application?


I would suggest that you create a new .bat file that launches the vcvars.bat and then your application. This will make sure that the environment is setup appropriately.


The VSVAR32.bat file just modifies some environment variables (appends a directory to path, sets LIB and INCLUDE, etc.). You can always make the same changes to the main Windows envirnonment so they are inherited by all subsequent processes (from the control panel "system" applet).

Quite a few other development tools use the same environment variables (including earlier Visual Studio versions). Making the configuration changes in the main environment is not so convenient when you want to use development tools that require conflicting settings on the same PC (that's why Microsoft puts them in MSVAR32.bat instead of modifying the main environment). , so it is useful to only apply these settings when they are required, as they conflict by the settings required by other development tools. Putting these changes in the main environment casues problems if you want to use different developmemnt tools on the same PC.

The other possibility to to have your application that will invoke csc.exe modify the enviroment it passes to the child process in the same manner as MSVAR32.bat.


Try to add the command to run it in the autoexec.NT file in windows directory.


Like laurent-rpnet says, you can call it in your autoexec.nt file. Alternately, you can add the environmental variables that it sets to the list in Control Panel | System | Advanced | Environment Variables.

Or you could create a make file and put them in there (or call the bat), and use the make file to build your project from the command line.

0

精彩评论

暂无评论...
验证码 换一张
取 消