views:

92

answers:

4

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 environment 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?

A: 

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

laurent-rpnet
what does it do?
Louis Rhys
it runs each time you start the command prompt.Open autoexec.nt (in windows directory) and edit it to add the command you would type on the keyboard to run the .bat
laurent-rpnet
continuation: You can put the content of the VSVARS32.bat in the autoexec.NT or add c:\path_to_\VSVARS32.bat at the end of autoexec.nt.autoexec.nt is in system32 directory - I can't remember now and I can't test it as my machine is not windows since some time but I think you need to use `command.com` instead of `cmd.exe` for autoexec.nt to be used.
laurent-rpnet
A: 

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.

Marc Bernier
again, what does autoexec.nt do, and how do i do it?the batch file has a lot of contents, including conditionals and other things that I don't completely understand, so I don't know what exactly I should add in control panel's environment variable
Louis Rhys
autoexec runs as soon as you log on. So, any variables you set there will be available throughout the duration of your session.
Vulcan Eager
oh how do I add it to autoexec?
Louis Rhys
+1  A: 

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.

Mike
this works for me. Thanks
Louis Rhys
A: 

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.

Stephen C. Steel