How to run vsvars32.bat to make its changes persistent?

  • Thread starter Thread starter Richard Lionheart
  • Start date Start date
R

Richard Lionheart

Hi All,

I opened a Command window and changed its directory to one that contained a
HelloWorld.cs program.

I ran "csc HelloWorld.cs" and got:

'csc' is not recognized as an internal or external command,
operable program or batch file.

I ran "vsvars32" and got:

Setting environment for using Microsoft Visual Studio .NET tools. [snip]

(which worked because I had previously amended PATH to include
"[snip]\Microsoft Visual Studio .NET\Common7\Tools")

Of course, if I opened another Command window, "csc HelloWorld.cs" would
again give rise to the "'csc' is not recognized" message because the changes
made to the environment variables in the first window were made only to the
session in which that window was created.

I thought if I ran "vsvars32" in Start | Run the changes would be
persistent, but that has proven not the case.

I used vcvars32 in the Win2000Pro environment with no problems. What is
going on here?

TIA,
Richard
 
XP don't use .bat file anymore!

However if you do: My Computer => Properties => Advanced => Environment
Variable
You could setupt global (or user dependent) environment variable, such as
the Path...
 
Hi Lloyd,

Thanks for confirming that XP doesn't honor .bat files to set environment
variables. But there ought to be a programmatic way to do the setup that
vsvars32.bat offered to setup. How about Web Script Host?

I just think doing it manually through the Environt page (which I accessed
through Start | Control Panel | System | Environment; Microsoft offers more
that one way to skin a cat, eh?).

Regards,
Richard
 
Lloyd Dupont said:
XP don't use .bat file anymore!

Yes it does! Do you mean it doesn't use autoexec.bat? That would be
reasonable - but it certainly *does* use batch files.
However if you do: My Computer => Properties => Advanced => Environment
Variable
You could setupt global (or user dependent) environment variable, such as
the Path...

Indeed.
 
Lloyd Dupont said:
Yes it does! Do you mean it doesn't use autoexec.bat? That would be
reasonable - but it certainly *does* use batch files.
Yep, it's what I meant.
 
command.com still uses autoexec.nt and config.nt which are batch files.
 
Just testing eclipse right now.
Hey, much better than the version I tested earlier!
I'm still confused by some UI concepts but that looks good.
Beside I'm delving into SWT sourcecode to solve of my Uniscribe rendering
problems, that's great!
 
Hi Guys,

Somehow, I think we got buried in the minutiae and lost sight of the
central question. I wanted to run vsvars32.exe in order to augment the
environment variables PATH, INCLUDE, LIB, and whatever else it my do.

I did that, if for no other reason, than to be assured the csc.exe would be
found when it was invoked from a Command window or from within .bat files,
regards what the current directory happened to be in the context of such
invocations.

I augmented the PATH (using Start/Control Panel/System/Environment to
augment PATH with the path to Microsoft Visual Studio .NET\Common7\Tools.
Then I invoked vsvars32.exe from Start | Run. That did not end up altering
PATH, according to Start/Control Panel/System/Environment.

Lloyd Dupont suggested the Windows XP no longer uses .bat files. But that's
a distraction. The real question is: How should I run vsvars32.exe so that
the environment variables are updated for various Visual Studio.Net
functionality works as expected?

From the discussion I've seen in this thread, I inclined to think I should
invoke vsvars32.exe from with autoexec.nt. Is that a correct solution? If
not, what is? (In the meantime, I'm going to try that.)

Thanks to all of you for hanging in until I get a resolution of this
question.

Best wishes,
Richard
 
Richard Lionheart said:
Somehow, I think we got buried in the minutiae and lost sight of the
central question. I wanted to run vsvars32.exe in order to augment the
environment variables PATH, INCLUDE, LIB, and whatever else it my do.

I did that, if for no other reason, than to be assured the csc.exe would be
found when it was invoked from a Command window or from within .bat files,
regards what the current directory happened to be in the context of such
invocations.

I augmented the PATH (using Start/Control Panel/System/Environment to
augment PATH with the path to Microsoft Visual Studio .NET\Common7\Tools.
Then I invoked vsvars32.exe from Start | Run. That did not end up altering
PATH, according to Start/Control Panel/System/Environment.

Running vsvars32 from Start | Run won't do anything useful. It'll
change the environment variables for the new command shell, then exit
that shell.
Lloyd Dupont suggested the Windows XP no longer uses .bat files. But that's
a distraction. The real question is: How should I run vsvars32.exe so that
the environment variables are updated for various Visual Studio.Net
functionality works as expected?

You don't - you update the path in the same way that vsvars32 would do
*if* you ran it, and then when you start a command prompt you won't
*need* vsvars32, as everything will already be set up.
 
Great answer, Jon! It solved my problem, and that's my main goal.
You don't - you update the path in the same way that vsvars32 would do
*if* you ran it, and then when you start a command prompt you won't
*need* vsvars32, as everything will already be set up.

I am saddened a little that there's not a more elegant solution. I'm sure I
never did this for Visual Studio 6.0 with MFC, ATL, etc. But since
everything seems to work as I expect, I'll get over it :-)

Thanks again for hanging in there with me.

Best wishes,
Richard
 
Back
Top