Click here to Skip to main content
16,017,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,
I want to set environment variables for VS2008 by running "vcvars32.bat" as administrator in the VS2008 installation folder. But "vcvars32.bat"is not working and not setting env. variables. i tried to add it manually but the content of "vcvars32.bat" file is pretty difficult.
Posted
Updated 24-Apr-12 0:40am
v3

If you start from the Start Menu, then find Visual Studio 2008 and drill down to the Visual Studio 2008 Tools, you'll find a Visual Studio Command Prompt (2008).

That starts a command window and sets the environment at the same time. As long as you leave it open, you'll have the variables.

Hope that helps.
 
Share this answer
 
Comments
ahsanriaz1K 25-Apr-12 0:43am    
Yeah that's working fine. Thanks a lot for your solution.
ahsanriaz1K 25-Apr-12 0:58am    
Can you please tell me that by doing according to your above mentioned comment, where do environment variables set?
krmed 25-Apr-12 6:35am    
When you open a command prompt (let's say without the Visual Studio Command prompt) and type the command "set" (without the quotes), you see all of your environment variables.

Now if you open the VS Command Prompt and type set, you'll see all of the ones that now exist - including those set by Visual Studio. However, as Aescieal explained, they are set within the current process ONLY. This means that once you open the Visual Studio command prompt, the variables exist, but the go away when you close that command prompt.

If you start a program from that command window, the program you start will inherit those variables since it is a child process of the command window.

Hope that explains well enough.
Each process has it's own environment. If you change the environment then ONLY child processes of the one doing the changing sees the new or modified variable. Any environment variables set in a process only last until that process terminates.

So if you double click on VCVARS32.BAT the following happens:

- Windows sees you're launching a batch file, it executes cmd /c "VCVARS32.BAT"
- The Windows loader creates a copy of EXPLORER.EXE's environment and attaches it to CMD.EXE's process.
- CMD.EXE starts and runs the batch file, setting the environment variables for its process, changing its copy of the environment
- CMD.EXE terminates and along with it goes the copy of the environment.

So if you want to change the root environment for a particular user your best bet is to go to control panel and do it there or let the VC++ installer make the changes.

Cheers,

Ash

PS: If you give us some details of WHY you want to do this then someone might have a better suggestion
 
Share this answer
 
Comments
ahsanriaz1K 24-Apr-12 7:38am    
Actually, i did some compilations through cmd.exe using compiler of VS2005 and set the variables manually from "vcvars32.bat". I want to do the same for the VS2008.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900